14

I really didn't want to start my own question with this because it seems to be a common error here. However, having wasted hours on this now and having followed every thread I could find, none of the given answers have sorted this for me.

So my only option is to provide all the information I can about my set up and hope one of you lot can recognise the problem.

I'm running on windows 10(x64) and have installed the following prebuilt binaries from the collection here.

  1. python 3.5.0-win32 (installed from python website)
  2. numpy 1.10-cp35-win32
  3. matplotlib 1.4.3-cp35-win32
  4. opencv 3.0.0-cp35-win32

Everything was installed using "pip install file_name.whl" with no error messages. However the difference is open cv will not import and I get the following error:

>>> import cv2
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.4\helpers\pydev\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ImportError: DLL load failed: The specified module could not be found.

cv2.cp35-win32.pyd plus many .dll files are installed to C:\Python35\Lib\site-packages

I've tried renaming cv2.cp35-win32.pyd to cv2.pyd and copying the .dll files to C:\Python35\DLLs

I've tried using another python opencv package downloaded from the site, adding the bin directory to my PATH environment and moving the cv2.pyd file to C:\Python35\Lib\site-packages

The same error appears every time. Any help would be appreciated!

Luke Vincent
  • 1,266
  • 2
  • 19
  • 35

7 Answers7

11

In my situation, when using Pycharm to import cv2, it returned ImportError: DLL not found. However, using python intepreter to import I got *ImportError: ... not a win32 DLL ... * instead. So, in this situation, I had to download Visual C++ 2015 redistribution package and problem solved.

So to anyone who meets the same error, please make sure you have the VC++ redistribution package which was used to compile the DLL packed along the module.

Brian Ng
  • 1,005
  • 12
  • 13
  • I think this is the right answer. Importantly I had to unistall everything to do with Python including everything in the path variable before trying again from the beginning. This time I included the VC++ Redistributable and it seemed to work. – Luke Vincent Jan 31 '16 at 23:51
  • I wouldn't say this addresses the question posted. In my case I get the same error both in Pycharm as well as in the IDLE "The specified module could not be found" – Iustinian Olaru Apr 13 '18 at 10:36
8

I had the error with Python 3.4 and opencv-python 3.3 on Windows 10. In my case the problem was due to my Anaconda distribution. I solved it with the solution from the opencv-python project page, which points to this github issue.

The problem is a missing python3.dll in the anaconda distribution. You can download the python binaries here and extract dll out of the zip archive. Put it in a folder in your PATH (e.g. C:\Users\MyName\Anaconda3) and the import should work.

RedPanda
  • 522
  • 6
  • 15
  • +1 this worked for me, but after downloading the appropriate python3.dll version (not necessarily the 3.5.2 version pointed by the link in the answer). _E.g._ check `python -V` or `conda info` to find out the python version, and then find the appropriate release in this list: https://www.python.org/downloads/). Thanks! – danbanica Feb 11 '18 at 20:40
5

This worked for me:

pip install opencv-contrib-python

(Running Python 3.6.3 - 32bit, on Windows 7 - 64bit)

ndmeiri
  • 4,979
  • 12
  • 37
  • 45
Ari
  • 326
  • 2
  • 5
  • 2
    In case anyone was wondering, opencv-python contains the main modules and opencv-contrib-python contains the main modules plus additional contrib modules, see https://pypi.org/project/opencv-python/ (do not try to install both of these!) – orangecaterpillar Sep 25 '19 at 13:15
  • 1
    This worked for me on windows 10 running python 3.6.3 64 bit – orangecaterpillar Sep 25 '19 at 13:26
2

In my case (for Windows OS), issue is solved by

Adding opencv DLLs path to PATH environment variable.

You can follow this guide on how to add path to an environment variable

Jumabek Alikhanov
  • 2,305
  • 3
  • 21
  • 21
1

Ok so I've got it working by completely uninstalling everything and starting from the beginning with Python 2.7.10.

It simply just does not work with Python 3. For clarity on what I did I followed these two videos in the order I'm posting them:

How to install opencv + dependencies

How to set up the path variable

Luke Vincent
  • 1,266
  • 2
  • 19
  • 35
0

I managed to solve the problem with uninstalling all Visual C++ Redistributable Packages until 2008 and then installing Visual C++ Redistributable Packages for VS 2015. The explanation is here: http://answers.opencv.org/question/74384/opencv-python-30-with-python-35-on-windows/

0

I had the same issue with Windows 10 Professionnal N and solved it just by installing the Media Feature Pack (and restarting windows after installation).

Windows N and KN editions do not include Media Feature Pack which is required by OpenCV. If you are using Windows N or KN edition, please install also Windows Media Feature Pack.

From https://github.com/skvark/opencv-python

Ismael EL ATIFI
  • 1,939
  • 20
  • 16