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 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?


You can install it using binstar:

conda install -c menpo opencv

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

conda install opencv currently works for me on UNIX/python2. This is worth trying first before consulting other solutions.

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.

Currently, I am using Windows 8.1 and 64-bit machine, Anaconda as IDE for Python 2.x.

Note: if you are on Windows 10 (or above) and if the below instruction works, please could you kindly add a comment? This will help out the community a lot! :-)


To use OpenCV fully with Anaconda (and Spyder IDE), we need to:

  1. Download the OpenCV package from the official OpenCV site
  2. Copy and paste the cv2.pyd to the Anaconda site-packages directory.
  3. Set user environmental variables so that Anaconda knows where to find the FFMPEG utility.
  4. Do some testing to confirm OpenCV and FFMPEG are now working.

(Read on for the detail instructions...)


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.

Install OpenCV-Python to Anaconda

Cautious Note: I originally tried out installing the OpenCV package, as suggested. That method however does not include the FFMPEG codec - i.e. you may be able to use OpenCV, but you won't be able to process videos.

The following instruction works for me is inspired by this OpenCV YouTube video. So far I have got it working on both my desktop and laptop, both 64-bit machines and Windows 8.1.

Download OpenCV Package

Firstly, go to the official OpenCV site to download the complete OpenCV package. Pick a version you like (2.x or 3.x). I am on Python 2.x and OpenCV 3.x - mainly because this is how the OpenCV-Python Tutorials are setup/based on.

In my case, I've extracted the package (essentially a folder) straight to my C drive (C:\opencv).

Copy and Paste the cv2.pyd file

The Anaconda Site-packages directory (e.g. C:\Users\Johnny\Anaconda\Lib\site-packages in my case) contains the Python packages that you may import. Our goal is to copy and paste the cv2.pyd file to this directory (so that we can use the import cv2 in our Python codes.).

To do this, copy the cv2.pyd file...

From this OpenCV directory (the beginning part might be slightly different on your machine):

# Python 2.7 and 32-bit machine:

# Python 2.7 and 64-bit machine:

To this Anaconda directory (the beginning part might be slightly different on your machine):


After performing this step we shall now be able to use import cv2 in Python code. BUT, we still need to do a little bit more work to get FFMPEG (video codec) to work (to enable us to do things like processing videos).

Set Environmental Variables

Right-click on "My Computer" (or "This PC" on Windows 8.1) → left-click Properties → left-click "Advanced" tab → left-click "Environment Variables..." button.

Add a new User Variable to point to the OpenCV (either x86 for 32-bit system or x64 for 64-bit system). I am currently on a 64-bit machine.

| 32-bit or 64 bit machine? | Variable     | Value                                |
| 32-bit                    | `OPENCV_DIR` | `C:\opencv\build\x86\vc12`           |
| 64-bit                    | `OPENCV_DIR` | `C:\opencv\build\x64\vc12`           |

Append %OPENCV_DIR%\bin to the User Variable PATH.

For example, my PATH user variable looks like this...





This is it we are done! FFMPEG is ready to be used!

Test to confirm

We need to test whether we can now do these in Anaconda (via Spyder IDE):

  • Import OpenCV package
  • Use the FFMPEG utility (to read/write/process videos)
Test 1: Can we import OpenCV?

To confirm that Anaconda is now able to import the OpenCV-Python package (namely, cv2), issue these in the IPython console:

import cv2
print cv2.__version__

If the package cv2 is imported OK with no errors, and the cv2 version is printed out, then we are all good! Here is a snapshot:


Test 2: Can we Use the FFMPEG codec?

Place a sample input_video.mp4 video file in a directory. We want to test whether we can:

  • read this .mp4 video file, and
  • write out a new video file (can be .avi or .mp4 etc.)

To do this we need to have a test Python code, call it Place it in the same directory as the sample input_video.mp4 file.

This is what may look like (I've listed out both newer and older version codes here - do let us know which one works / not work for you!):

(Newer version...)

import cv2
cap = cv2.VideoCapture("input_video.mp4")
print cap.isOpened()   # True = read video successfully. False - fail to read video.

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter("output_video.avi", fourcc, 20.0, (640, 360))
print out.isOpened()  # True = write out video successfully. False - fail to write out video.


(Or the older version...)

import cv2
print cv2.isOpened()   # True = read video successfully. False - fail to read video.

fourcc =*'XVID')
out = cv2.VideoWriter("output_video.avi",fourcc, 20.0, (640,360))
print out.isOpened()  # True = write out video successfully. False - fail to write out video.


This test is VERY IMPORTANT. If you'd like to process video files, you'd need to ensure that Anaconda / Spyder IDE can use the FFMPEG (video codec). It took me days to have got it working. But I hope it would take you much less time! :)

Note: One more very important tip when using the Anaconda Spyder IDE. Make sure you check the current working directory (CWD)!!!


To use OpenCV fully with Anaconda (and Spyder IDE), we need to:

  1. Download the OpenCV package from the official OpenCV site
  2. Copy and paste the cv2.pyd to the Anaconda site-packages directory.
  3. Set user environmental variables so that Anaconda knows where to find the FFMPEG utility.
  4. Do some testing to confirm OpenCV and FFMPEG are now working.

Good luck!

It doesn't seem like the page you linked includes opencv any more. (Funny, I do recall it being included at a previous point as well.)

In any case, installation of OpenCV into Anaconda, although unavailable through conda, is pretty trivial. You just need to download one file.

  1. Download OpenCV from and extract
  2. From the extracted folder, copy the file from the extracted directory: opencv/build/python/2.7/(either x86 or x64, depending on your Anaconda version)/cv2.pyd to your Anaconda site-packages directory, e.g., C:\Anaconda\Lib\site-packages
  3. To get FFmpeg within opencv to work, you'll have to add the directory that FFmpeg is located in to the path (e.g., opencv/sources/3rdparty/ffmpeg). Then you'll have to find the DLL file in that folder (e.g., opencv_ffmpeg_64.dll) and copy or rename it to a filename that includes the opencv version you are installing, (e.g., opencv_ffmpeg249_64) for 2.4.9.

Now at the Python prompt you should be able to type "import cv2" verify that it works, type "print cv2.__version__", and it should print out the OpenCV version you downloaded.

To install OpenCV in Anaconda, start up the Anaconda command prompt and install OpenCV with

conda install -c opencv3

Test that it works in your Anaconda Spyder or IPython console with

import cv2

You can also check the installed version using:


You can install OpenCV 3 by running any of this commands in the Anaconda command prompt:

conda install -c menpo opencv3

conda install -c conda-forge opencv

mempo channel is not supported anymore.

It worked on Windows 10 and Ubuntu 14.


The following installs opencv from conda-forge (note: tried on Windows)

conda config --add channels conda-forge
conda install opencv

I had exactly the same problem, and could not get conda to install OpenCV. However, I managed to install it with the OpenCV installer you find at this site:

His files are "Wheel" whl files that can be installed with pip, e.g.

pip install SomePackage-1.0-py2.py3-none-any.whl

in a command window. It worked with Spyder directly after executing this command for me. I have had the same experience with other packages, the above UC Irvine site is a gold mine.

I entered the following command in the command prompt:

conda install -c menpo opencv=2.4.11

This worked for me!!!

To install OpenCv with conda on Windows-64 and Python 3.5, the only one that worked for me is:

conda install -c conda-forge opencv=3.1.0 

Like others, I had issues with Python 3.5.1/Anaconda 2.4.0 on OS X 10.11..

But I found a compatible package here:

It can be installed via the command line like so:

 conda install -c opencv3

Worked like a charm. First time I've ever gotten OpenCV to work on 3.x!

Windows only solution. OpenCV 3.x pip install for Python 3.x

Download .whl file (cpMN where you have Python M.N). contrib includes OpenCV-extra packages. For example, assuming you have Python 3.6 and Windows 64-bit, you might download opencv_python‑3.2.0+contrib‑cp36‑cp36m‑win_amd64.whl

From command prompt type:

pip install opencv_python‑3.2.0+contrib‑cp36‑cp36m‑win_amd64.whl

You'll have a package in your conda list : opencv-python 3.2.0+contrib <pip>

Now you could test it (no errors):

>>> import cv2

Original source page where I took the information is here.

On Linux, as discussed here, the best way to get opencv at present is from loopbio at conda-forge:

conda install -c loopbio -c conda-forge -c pkgw-forge ffmpeg-feature ffmpeg gtk2 opencv

If you have 'a modern CPU' there exists also a compiled version "enabling all modern CPU instruction set extensions [...] and against libjpeg-turbo":

conda install -c loopbio -c conda-forge -c pkgw-forge ffmpeg-feature ffmpeg gtk2 opencv-turbo`

Two of the solutions mentioned in other answers don't work unconditionally:

  • The conda you get through conda install opencv or pip install opencv-python doesn't have gtk2 support, so you can't display images through imshow.
  • Conda built by Menpo (conda install -c menpo opencv3) has gtk2 support, but
    • they have only built OpenCV 3.2 for Python 3.5, not Python 3.6
    • Ubuntu 16.10 has deprecated libpng12, leading to a missing dependency and the following error when trying to import cv2: ImportError: cannot open shared object file: No such file or directory, as discussed here

EDIT: @Yamaneko points out that as of 14 June 2017, "there is an issue with loopbio's OpenCV version 3.2.0. It silently fails to read and write videos. It is due to a combination of an upstream OpenCV issue in combination with an old GCC. More details here. There is a PR on its way to solve the issue."

An easy and straight forward solution is to install python3.5 first before installing opencv3

conda install python=3.5

followed by

conda install --channel opencv3 

To install the OpenCV package with conda, run:

conda install -c menpo opencv3=3.1.0

I think the easiest option that should work cross-platform and across various versions of Anaconda is

#Run Anaconda Prompt as an Administrator (on Windows) & execute the command below
#(you may need to use   sudo   on a Unix-Based or Mac system 
#to have the needed permissions)

conda install -c conda-forge opencv

If conda install opencv or conda install -c opencv does not work, you can try to compile from the source.

Download the source from, follow the install instruction in, (maybe you can jump to the last part directly, 'Building OpenCV from Source Using CMake...), change the cmake command as following:

mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/**/env/opencv-2.4.10 -D BUILD_NEW_PYTHON_SUPPORT=ON -D PYTHON_EXECUTABLE=/home/**/env/anaconda/bin/python -D PYTHON_INCLUDE_DIR=/home/**/env/anaconda/include/python2.7 -D PYTHON_LIBRARY=/home/**/env/anaconda/lib/ -D PYTHON_PACKAGES_PATH=/home/**/env/anaconda/lib/python2.7/site-packages -D PYTHON_NUMPY_INCLUDE_DIRS=/home/**/env/anaconda/lib/python2.7/site-packages/numpy/core/include ..

make -j4
make install

You will find in anaconda/lib/python2.7/site-packages.


import cv2
print cv2.__version__

It will print out 2.4.10.

My environment is GCC 4.4.6, Python 2.7 (anaconda), and opencv-2.4.10.

The correct command for installing the current version of OpenCV 3.3 in Anaconda windows:

conda install -c conda-forge opencv


conda install -c conda-forge/label/broken opencv

For 3.2 use this:

conda install -c menpo opencv3

In May 2019, the answer is as follows:

conda update freetype
conda install opencv

This updates libfreetype.6.dylib to 24.0.0 compatibility and installs OpenCV 4.1.0. I did not need to use -c conda-forge to specify the channel, though you can if the above does not work.

conda install -c opencv

Try this

You just copy the cv2.pyd file to the C:\Users\USERNAME\Anaconda2\Lib directory.

You get the cv2.pyd file at this link (

The cv2.pyd is located at C:\Users\USERNAME\Desktop\opencv\build\python\2.7\x64.

The following command works for me too. I am using an embedded IPython Notebook in Anaconda.

conda install -c opencv

I have just tried on two Win32 Python 3.5 computers. At first, I was able to conda install opencv, but it didn't work nor did the version from menpp, but this did:

conda install -c opencv

The OP did not specify that he absolutely needed a solution using the conda command, I think installing opencv is the easiest using the Anaconda Navigator application:

  1. open Anaconda Navigator (through your OS's start menu, for example),
  2. click the Environments tab on the left.
  3. Next to this tab, select the conda environment on which you want to install opencv (if you don't have a specific environment in mind, select the default base (root) environment).
  4. On the right, select Not installed in the drop down list and type 'opencv' in the filter box,
  5. select the 'opencv' package in the list,
  6. click 'apply' on the bottom of the application. Anaconda Navigator will now install opencv for you.

I installed it like this:

$ conda install --channel opencv

I tried conda install opencv directly, but it does not work for me since I am using Python 3.5 which is higher version that default OpenCV library in conda. Later, I tried 'anaconda/opencv', but it does not work either. I found finally that conda-forge/opencv works for Python 3.5.

I had steps in repo that will help you properly install OpenCV.

If the links if broken, see this.

For requirements and prerequisites follow this instructions:

YOU NEED TO HAVE WINDOWS OS to begin this project.

windows 7 to 10

Follow the steps carefully

  1. Install Anaconda2 32/64 python 2


    Install Anaconda3 32/64 python 3

    It Depends on System Information

    Along the way you must check all the options ignore the red text

    Then wait till installation completed ...

    Open CMD admin when finish installed

    Make sure that the anaconda-python is configured in CMD admin

  2. Type: python

    This will come out:

    C:\WINDOWS\system32>python Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 15 2017, 03:27:45)

    [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

  3. Next is to install packages:



    PyMySQL or pymysql

    Install and Import OpenCV

    conda install -c conda-forge opencv = (version optional)

    (click yes if there's updates)

    Install and Import Numpy

    pip install numpy

    (click yes if there's updates)

    Install and Import PyMySQL/pymysql

    pip install PyMySQL or pymysql

  4. When all the package is completely installed, then you must Reboot it.

    go to CMD admin again

    type "python"

    import cv2 (cv2 is OpenCV)

    import Numpy or numpy

    import pymysql

    import os

    from PIL from Image

    if all of then is ok.. your ready to run the code!!

    After you finish all the steps, you can now test the code in SPYDER python that I use

Although not through Conda, and this is specific to Ubuntu, the easiest way to install OpenCV with all its contrib modules built in such as SIFT and SURF is to use:

pip install opencv-contrib-python

It supports Python2.7+ and Python 3.4+

If you choose not to have the contribs built in, you could instead do:

pip install opencv-python

You need to install the following dependencies below before you run those commands though:

sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev

This is a good tutorial on setting OpenCV on Ubuntu:

I faced the same problem, but I have solved it now. This is what I did:

First enter conda install -c opencv in the command prompt and then find the path Anaconda\pkgs\opencv-\Lib\site-packages. Now copy all the files present here into Anaconda\Lib\site-packages. Now you will be able to use OpenCV with Python.

I just wanted to update the brilliant answer by Atlas7.

If you're using OpenCV 3, change the test code to the following:

import cv2
print cap.isOpened()   # True = read video successfully. False - fail to read video.

fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (640,480))
print out.isOpened()  # True = write out video successfully. False - fail to write out video.


Need Your Help

Set default value on Datetime field in symfony2 form

php symfony symfony-2.1

I have a form containing several fields. One of them is a Datetime field. How to define a default value for that field?