Skip to content

DLL load fails on Anaconda/Windows install (python3.dll) #36

@talmo

Description

@talmo

After doing a simple pip install opencv-python or pip install opencv-contrib-python and trying to import the library, I ran into this issue:

λ python Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\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. 

The readme suggests installing the Visual C++ Redistributable for Visual Studio 2015
but I already had it installed (actually had Visual Studio itself installed as well).

Checking the dependencies of the pyd binary in this package (using dumpbin which comes with Visual Studio):

λ dumpbin.exe C:\Anaconda3\Lib\site-packages\cv2\cv2.cp35-win_amd64.pyd /IMPORTS | grep dll python3.dll python35.dll MSVFW32.dll AVIFIL32.dll AVICAP32.dll KERNEL32.dll USER32.dll GDI32.dll ole32.dll OLEAUT32.dll COMDLG32.dll ADVAPI32.dll 

After checking if these were in the PATH I was surprised to find that python3.dll was the only one that wasn't!

Although python3.dll comes with the standard CPython install, it's not packaged with Anaconda for some reason. ContinuumIO/anaconda-issues#1394 references this and it seems like it's just not supported(?).

As a workaround suggested in that thread, I solved this by just copying python3.dll from the official CPython 3.5.2 binaries (specifically from the Windows x86-64 embeddable zip file) into C:\Anaconda3, although I imagine it would work being anywhere in your PATH.

I thought I'd share this bit of troubleshooting since Anaconda is a popular distribution among academics and so is OpenCV, so I figure I might not be the only one running into this issue. Maybe a note in the readme might help others until Anaconda resolves this?

Alternatively, the menpo/opencv3 Anaconda package would also work but I don't think it supports ffmpeg nor opencv-contrib.

For reference, I'm running on Python 3.5.2 which came with Anaconda 4.2.0 (official installer), although conda info reports a slightly newer version:

λ conda info Current conda install: platform : win-64 conda version : 4.3.16 conda is private : False conda-env version : 4.3.16 conda-build version : 2.0.2 python version : 3.5.2.final.0 requests version : 2.12.4 root environment : C:\Anaconda3 (writable) default environment : C:\Anaconda3 envs directories : C:\Anaconda3\envs C:\Users\Talmo\AppData\Local\conda\conda\envs C:\Users\Talmo\.conda\envs package cache : C:\Anaconda3\pkgs C:\Users\Talmo\AppData\Local\conda\conda\pkgs channel URLs : https://repo.continuum.io/pkgs/free/win-64 https://repo.continuum.io/pkgs/free/noarch https://repo.continuum.io/pkgs/r/win-64 https://repo.continuum.io/pkgs/r/noarch https://repo.continuum.io/pkgs/pro/win-64 https://repo.continuum.io/pkgs/pro/noarch https://repo.continuum.io/pkgs/msys2/win-64 https://repo.continuum.io/pkgs/msys2/noarch config file : None offline mode : False user-agent : conda/4.3.16 requests/2.12.4 CPython/3.5.2 Windows/10 Windows/10.0.15063 

Cheers and thanks for all the work you put into this repo!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions