2

I want to have Python 3 support in OpenCV, so I read that I need to build my own version with it.

I downloaded OpenCV 3 beta from SourceForge, then I used CMake to create a project, and then compiled it with Visual Studio. It has created lot's of files (not actually the same structure as in precompiled folder from Sourceforge), and also a cv2.pyd. I placed this file into Python34\lib\site-packages, and tried import cv2 in python console, but it says Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: Module not found.

What I did wrong? Thanks.

6
  • it sounds, like you made dynamic libs (dll's) for opencv. in that case, the folder with those (like e:\opencv\build\bin\release) must be appended to the PATH variable, so cv2.pyd can find them at runtime. Commented Mar 5, 2015 at 16:17
  • From my experience (at least it used to be so), there is also a cv2.dll that OpenCV generates when built on windows, which should go into the same folder as cv2.pyd. Having said that, I'm not sure how things work there nowadays, and berak may be right. Regardless, it's a good practice to have the correct dlls in your environment's PATH, rapid environment editor is the usual freeware of choice to set that up on Windows. Commented Mar 5, 2015 at 16:46
  • Ok. I add new variables to path, but it doesn't help. And I don't see cv2.dll or any similar library in the folder. Honestly, I expected that after compilation I will get some install file, that will perform regular installation process. Commented Mar 5, 2015 at 16:59
  • Have you built the INSTALL target (subproject) in visual studio? In my experience, for the Windows platform that won't do everything that you expect by default, but at least it will move everything to a specific folder ("install", if I recall correctly) within the root opencv directory, and possibly move the python-related files into their proper destinations. See what that gives you. Also, what architecture is your python install and what architecture are you compiling for? In certain cases, a mismatch between those can cause a DLL load error. Commented Mar 5, 2015 at 17:04
  • Also, make sure you reload the python shell completely (not sure which shell you use, but if it's just from windows command prompt, restart that too) every time you try something. Commented Mar 5, 2015 at 17:08

1 Answer 1

1

If you want to avoid building your own version, Christoph Gohlke maintains Windows binaries for many Python packages, including the production version of OpenCV 3.0 with Python 3.x bindings, released 4 June 2015:

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 run pip install [filename]. Then the instruction import cv2 should work in your Python 3.x interpreter.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.