How Do I Install Python Opencv Through Conda?
I'm Trying to Install Opencv for Python Through Anaconda, but I Can't Seem to Figure This Out. I Tried Conda Install Opencv Conda Install Cv2 I Also Tried...
I'm trying to install OpenCV for Python through Anaconda, but I can't seem to figure this out.
I tried
conda install opencv
conda install cv2
I also tried searching
conda search cv
No cigar. I ran across this which lists opencv as an included package:
After running conda info I noticed my version is 3.4.1, but I couldn't seem to find any information about this version online. I'm pretty confused about this.
Am I missing something pretty obvious here? If opencv was available for a previous version of Anaconda, then why wouldn't it be available for the newer version? And why does that link only show me documentation for version 1.9.2?
43 Answers
You can install it using binstar:
conda install -c menpo opencv
conda install opencv currently works for me on UNIX/python2. This is worth trying first before consulting other solutions.
This worked for me (on Ubuntu and conda 3.18.3):
conda install --channel opencv3
The command above was what was shown to me when I ran the following:
anaconda show menpo/opencv3
This was the output:
To install this package with conda run:
conda install --channel opencv3
I tested the following in python without errors:
>>> import cv2
>>>
I have summarized my now fully working solution, OpenCV-Python - How to install OpenCV-Python package to Anaconda (Windows). Nevertheless I've copied and pasted the important bits to this post.
At the time of writing I was using Windows 8.1, 64-bit machine, Anaconda/ Python 2.x. (see notes below - this works also for Windows 10, and likely Python 3.x too).
NOTE 1: as mentioned mentioned by @great_raisin (thank you) in comment section however, this solution appears to also work for Windows 10.
NOTE 2: this will probably work for Anaconda/Python 3.x too. If you are using Windows 10 and Anaconda/Python 3.x, and this solution works, please add a comment below. Thanks! (Update: noting from comment "Working on Windows 10")
NOTE 3: depending on whether you are using Python 2.x or 3.x, just adjust the
printstatement accordingly in code snippets. i.e. in Python 3.x it would beprint("hello"), and in Python 2.x it would beprint "hello".
TL;DR
To use OpenCV fully with Anaconda (and Spyder IDE), we need to:
- Download the OpenCV package from the official OpenCV site
- Copy and paste the
cv2.pydto the Anaconda site-packages directory. - Set user environmental variables so that Anaconda knows where to find the FFMPEG utility.
- Do some testing to confirm OpenCV and FFMPEG are now working.
(Read on for the detail instructions...)
Prerequisite
Must Read
Install Anaconda
Anaconda is essentially a nicely packaged Python IDE that is shipped with tons of useful packages, such as NumPy, Pandas, IPython Notebook, etc. It seems to be recommended everywhere in the scientific community. Check out Anaconda to get it installed.