Reputation: 6727
This question is different from "How do I install Python OpenCV through Conda?" because that question was asked more than 5 years ago, when all packages had different versions. I tried ALL answers to that question, and neither worked. See the text of question for details.
How to install opencv with conda now, in July 2019? On a freshly installed anaconda, I did conda update conda
(succesfully) then tried the following:
(base) C:\Users\mlearning>python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
>>> import cv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv'
(base) C:\Users\mlearning>conda install -c menpo opencv3
Collecting package metadata (repodata.json): done
Solving environment: (goes into infinite loop, after 10 minutes I pressed ^C)
(base) C:\Users\mlearning>conda install opencv
Collecting package metadata (repodata.json): done
Solving environment: failed
Initial quick solve with frozen env failed. Unfreezing env and trying again.
Solving environment: failed
UnsatisfiableError: The following specifications were found to be incompatible with each other:
Package zipp conflicts for:
importlib_metadata -> zipp[version='>=0.3.2']
path.py -> importlib_metadata[version='>=0.5'] -> zipp[version='>=0.3.2']
anaconda==2019.03=py37_0 -> importlib_metadata==0.8=py37_0 -> zipp[version='>=0.3.2']
zipp
Package importlib_metadata conflicts for:
anaconda==2019.03=py37_0 -> importlib_metadata==0.8=py37_0
path.py -> importlib_metadata[version='>=0.5']
Package hdf5 conflicts for:
anaconda==2019.03=py37_0 -> h5py==2.9.0=py37h5e291fa_0 -> hdf5[version='>=1.10.4,<1.10.5.0a0']
hdf5
opencv -> hdf5[version='>=1.10.2,<1.10.3.0a0,>=1.8.18,<1.8.19.0a0,>=1.8.20,<1.9.0a0']
h5py -> hdf5[version='>=1.10.1,<1.10.2.0a0,>=1.10.2,<1.10.3.0a0,>=1.10.4,<1.10.5.0a0,>=1.8.18,<1.9.0a0']
pytables -> hdf5[version='>=1.10.1,<1.10.2.0a0,>=1.8.18,<1.8.19.0a0,>=1.8.18,<1.9.0a0']
Package mkl-service conflicts for:
mkl-service
anaconda==2019.03=py37_0 -> mkl-service==1.1.2=py37hb782905_5
(base) C:\Users\mlearning>conda install -c conda-forge opencv
Collecting package metadata (repodata.json): done
Solving environment: failed
Initial quick solve with frozen env failed. Unfreezing env and trying again.
Solving environment: failed
UnsatisfiableError: The following specifications were found to be incompatible with each other:
Package hdf5 conflicts for:
anaconda==2019.03=py37_0 -> hdf5==1.10.4=h7ebc959_0
h5py -> hdf5[version='1.10.1,1.8.17|1.8.17.*,1.8.18|1.8.18.*,>=1.10.2,<1.10.3.0a0,>=1.10.3,<1.10.4.0a0,>=1.8.20,<1.9.0a0']
pytables -> hdf5[version='1.8.18|1.8.18.*,>=1.10.4,<1.10.5.0a0,>=1.8.18,<1.8.19.0a0,>=1.8.18,<1.9.0a0']
hdf5
Package mkl-service conflicts for:
mkl-service
Package importlib_metadata conflicts for:
importlib_metadata
path.py -> importlib_metadata[version='>=0.5']
Upvotes: 19
Views: 50550
Reputation: 6284
opencv
is now available on the main anaconda channel, so contrary to older answers there is now no need to use conda-forge
(unless you need other dependencies that are only available from there) or pip
(assuming you would prefer to use conda
).
To create a new environment named myopencvenv
with opencv, use
conda create -n myopencvenv opencv
Upvotes: 0
Reputation: 107
The easiest way is:
conda install pip
pip install opencv-python
Have fun!
Upvotes: 0
Reputation: 14094
I have had countless problems with installing opencv with conda This is my approach, create an env if you don't already have one
conda create -n py36 python=3.6
conda activate py36
Install opencv with pip
NOT conda
pip install opencv-python
If your still having an issue, uninstall opencv, update ffmpeg
conda install -c conda-forge ffmpeg
then rerun pip
UPDATE 2020
install pip with you env activate
conda install pip
verify pip is in your env
whereis
pip: /path/anaconda3/envs/your_env/bin/pip
Install opencv with pip
~/anaconda3/envs/your_env/bin/pip3 install opencv-python
Upvotes: 18
Reputation: 125
I faced a similar issue. Installed it with the following and it is working for me:
pip install opencv-python
The pypi for the above is at https://pypi.org/project/opencv-python/
Upvotes: 1
Reputation: 116
Create a complete new environment and let conda deal with compatibilities:
conda create -n cv -c conda-forge opencv matplotlib
This will create a new environment named "cv" with python, opencv and matplotlib.
Today (Out. 11th, 2019) it installed:
Upvotes: 9
Reputation: 131
I faced similar problem (only hdf5 conflicted). The reason is using incompatible version python.
How about creating new python3.6 environment before installing openCV? You can create new environment like this.
$ conda create -n py36 python=3.6
In addition you should also type this command to activate.
$ activate py36
Upvotes: 2