Python 3.5, OpenCV 3.2, Windows 7 64-bits, Anacond

2019-02-19 05:23发布

问题:

So many questions already about this topic, but I didn't find any satisfying answer about the "DLL not found" traditional issue.

  • I'm using Python 3.5 installed via Anaconda 3;
  • I have installed with pip the 'official' opencv_python-3.2.0.6-cp34-cp34m-win_amd64.whl (right from here https://pypi.python.org/pypi/opencv-python);
  • Windows version is 7 - 64 bits;
  • I have uninstalled all the redistributable VC++ that were present on my machine and reinstalled its 2015 version - so the famous as well as mandatory DLL msvcp140.dll is present on my laptop;
  • the cv2 module is present in the Lib/site-packages directory;
  • it contains, among others, file 'cv2.cp35-win_amd64.pyd'.

Meanwhile, I still can't get access to cv2:

>>> import cv2
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import cv2
  File "C:\Program Files\Anaconda3\lib\site-packages\cv2\__init__.py", line 7, in <module>
    from . import cv2
ImportError: DLL load failed: The specified module could not be found.

Modifying the name of the .pyd --> cv2.pyd does not solve the problem, nor does the installing via pip of the unofficial but great wheel version from Gohlke (http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv)

Any idea about what is going on?

回答1:

As mentioned in the comment which I didn't notice at first, you can resolve this by installing from the unofficial site (Gohlke) (http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv)

I uninstalled the official one by calling:

pip uninstall opencv-python

And then downloaded the .whl package from the mentioned site (you need to carefully choose the correct python version and the correct processor architecture x86 or x64).

And then, go to the path where the .whl file is downloaded and call:

pip install opencv_python-x.x.x-cpxx-cpxxm-win_xx.whl


回答2:

Regarding the comment in the question, always remove any existing opencv package before installing another one because, opencv from unofficial and official sites will be considered as 2 packages by pip.

You can install official opencv if you follow my answer here. You get that error because of a problem with Anaconda.

But if you install official opencv it will autocomplete and give suggestions in your python IDE (see this). So, if you need autocomplete as well, you need to go with unofficial opencv.



回答3:

I had the same issue. This helps me:

conda install -c menpo opencv3

Find at https://www.scivision.co/install-opencv-python-windows/