This question already has an answer here:
- Install opencv for Python 3.3 13 answers
I've been searching around the Internet for a while but I have not been able to find detailed instructions on how to install OpenCV for Python 3.x under Windows.
I would really appreciate if anyone here can share his/her method if he/she had successfully installed OpenCV for Python 3.x, either from a pre-built binary or from the source code, for either version OpenCV 2.x or OpenCV 3.x.
OpenCV 3 added python 3+ support. It is still in alpha and there are a lot of known bugs with it and python at the moment. The final version of OpenCV 3 will be released by the end of the year.
If you download the OpenCV 3 alpha executable from the website, you can build the support for python 3. Alternatively, you can get the latest code from their github. You will also have to install CMake and Python 3. Open up CMake and it will ask where the source code is. If you downloaded the executable, it will be located where ever you extracted the executable at in the sources folder. If you downloaded the latest build, it is wherever you downloaded that. Select the folder and in CMake, hit configure and it will ask you which compiler you want to use. After that, you can see everything you can build in OpenCV. As of OpenCV 3, there is an option for Python3. Check that and anything else you might want, and hit generate. That will make a project within your compiler of choice that you can build, and that will build all of the library's you need.
While this guide is made for 2.4.9, it works for 3.0. You will just see different options within 3. http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html
For those on Windows who don't want to mess with building OpenCV 3.0 from source, Christoph Gohlke maintains Windows binaries for many Python packages, including OpenCV 3.0 with Python 3.x bindings! See here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
To install, just download the 64-bit or 32-bit
.whl
file appropriate for your system, then runpip install [filename]
. Then the instructionimport cv2
should work in your Python 3.x interpreter.For Windows users, I strongly recommend forgetting about Python 3.x and install WinPython 2.7 https://sourceforge.net/projects/winpython/files/WinPython_2.7/2.7.10.3/
then, after installing opencv, just move the file opencv\build\python\x86\2.7\cv2.pyd to *WinPython-64bit-2.7.6.3\python-2.7.6\Lib\site-packages*
Now, open Spyder.exe, found in your WinPython folder, and execute (
This is the easiest way to have opencv running on windows.