Install OpenCV for Python on Mac OS X or Linux

The previous post describes how to install OpenCV using Homebrew.

In this post we describe how to install OpenCV 3 for Python 3+ using Anaconda.

Anaconda is the leading open data science platform powered by Python. The open source version of Anaconda is a high performance distribution of Python and R and includes over 100 of the most popular Python, R and Scala packages for data science.

Install python, matplotlib, numpy, opencv, ffmpeg for image and video processing using python 3.

Install anaconda:

Download anaconda form here: https://www.continuum.io/downloads
With Anaconda you have an easy way to manage packages and keep every environment separate from each other.

If you want, you can deactivate the environment using:

Check python is installed correctly:

Ctrl + D to exit python (or type exit() then hit enter).

Install OpenCV:

Test OpenCV is installed without errors:

If everything is ok you won’t see anything printed (meaning no errors when importing the library).

Install moviepy:

Install moviepy for processing video:

and check that the install worked:

You may also need to also install ffmpeg for video processing using moviepy: