Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I install OpenCV for Python 3.4?

Tags:

python

opencv

I use Python 3.4 through Anaconda distribution. They don't seem to have Python 3.4 bindings for OpenCV. I tried to use Cmake from the source, but to no avail. Could anybody please help me to install OpenCV for Python 3.4.x?

like image 731
user3317287 Avatar asked Feb 05 '15 22:02

user3317287


People also ask

Is OpenCV compatible with Python 3?

There are two major versions of Python, Python2, and Python3. We will be covering the latest version of Python throughout the tutorials as it supports newer features. The OpenCV doesn't care much about the version of Python, the bindings will work just the same.


2 Answers

conda install -c menpo opencv3

Does the trick. However you have to have anaconda installed.

like image 88
JSalys Avatar answered Sep 23 '22 07:09

JSalys


There are many tutorials and questions (on SO) about this.

This seems to answer your question. Edit: Reproduced below:

1)  Download OpenCV from http://opencv.org/downloads.html 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 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.

{End Reproduction}

EDIT2: OpenCV doesn't support Python 3.x except for OpenCV version 3.0 (still experimental, in beta). Download the 3.0 version from the download site and try that.(Thanks to this question).

A SO question with a possible tip, if the previous doesn't work.

And finally, I will point you to a read the docs tutorial on how to install it.

Good luck!

like image 43
IronManMark20 Avatar answered Sep 23 '22 07:09

IronManMark20