Installing opencv 3.1 with anaconda python3?
Solution 1
I think you don't need to build OpenCV for anaconda, there is this very handy tool called 'conda' that is available in your terminal once you have installed the Anaconda python distribution.
I found this site which gives instruction on how to install opencv3
https://anaconda.org/menpo/opencv3
I personally installed it myself so just try follow along with these instructions.
If you have the Anaconda python distribution installed in your system, you can issue this command (assuming you are working on linux) fire up the terminal:
conda install -c menpo opencv
If the version of python install in your Anaconda is 2.7, the command above should install OpenCV 3.1, but if the version of your python is 3.5, then you should change 'opencv' in the last line to 'opencv3'
conda install -c menpo opencv3
This should install OpenCV in your Anaconda. To see if you have installed it successfully, fire up your Python and issue the following command:
import cv2 # import the opencv library
cv2.__version__ # this will print the version of your opencv3
Hope that helps =)
Solution 2
If you are getting an error like the following:
UnsatisfiableError: The following specifications were found to be in conflict:
opencv 2.4.11* -> numpy 1.9* -> python 2.6* -> openssl 1.0.1*
python 3.6*
Use "conda info " to see the dependencies for each package.
Just install python 3.5 and try again.
conda install python=3.5
conda install -c menpo opencv # whichever
conda install -c menpo opencv3 # you need
Solution 3
Try this method it worked for me. Anaconda3-4
conda create -n opencv
activate opencv
conda install -c https://conda.binstar.org/menpo opencv3
Solution 4
None of the methods above worked for me. However, I found that this one liner works for me:
conda install -c conda-forge opencv
Solution 5
With conda v4.3.16 and python v3.6 this command worked for me:
conda install -c anaconda opencv
Related videos on Youtube
Tamim Addari
Updated on July 09, 2022Comments
-
Tamim Addari almost 2 years
How do I install opencv with anaconda python3 , opencv picked up my python3 executables
-- Python 2: -- Interpreter: /usr/bin/python2.7 (ver 2.7.12) -- Libraries: /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12) -- numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0) -- packages path: lib/python2.7/dist-packages -- -- Python 3: -- Interpreter: /home/tamim/anaconda3/bin/python3 (ver 3.5.2) -- Libraries: /usr/lib/x86_64-linux-gnu/libpython3.5m.so (ver 3.5.2) -- numpy: /home/tamim/anaconda3/lib/python3.5/site-packages/numpy/core/include (ver 1.11.1) -- packages path: lib/python3.5/site-packages -- -- Python (for build): /usr/bin/python2.7
I installed opencv with the following make options
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D CUDA_NVCC_FLAGS="-D_FORCE_INLINES" ..
But after installing it I can't import cv2 within python3 of anaconda. I can however import cv2 from builtin python2 command. So I suppose it build for the python2 version as stated in the last line.
How do I build for anaconda python3 ?
-
Tamim Addari over 7 yearsDoes this install with cuda support ?
-
stevenferrer over 7 yearsI think the support for cuda is already in OpenCV. I found this link that says something about Cuda Module in OpenCV. You might wanna check it out. Here is the link: docs.opencv.org/3.1.0/d2/dbc/cuda_intro.html
-
Daniyar about 7 yearsMissing colon in URL for opencv3
-
nawfel bgh about 7 yearsThanks. This worked on 64bit Linux but not in 32bit Linux. In 32bit linux I get PackageNotFoundError
-
stevenferrer about 7 yearsYeah, I think there is no support for 32 bit linux
-
Eskapp almost 7 yearsThe full URL did not work for me (Python 3.5) but this worked
conda install -c menpo opencv3
-
Chakradhar K about 6 yearsI could get it work by building OpenCV from source with argument to CMake as " -D BUILD_opencv_python3=yes " for python 3 support
-
stevenferrer over 5 yearsIt will be very helpful to explain the reason for downvoting so that we can improve this answer. thanks.
-
Muhammad Raihan Muhaimin about 5 yearsThis method downgrade my python 3.6 to 2.7. However
conda install -c anaconda opencv
works. Probably this is the reason github.com/menpo/conda-opencv3/issues/21 -
stevenferrer about 5 yearsHi @MuhammadRaihanMuhaimin, thank you for that comment, Please feel free to update this answer :)
-
Owlright about 4 years@TamimAddari No, to get cuda support you have to build openCV from source with flag -D WITH_CUDA=ON