opencv import failed in windows container (on Windows Server 2016)

2.1k views Asked by At

I run the following container to test my opencv-python environment on Windows Server 2016.

docker run -i --rm python:2.7-windowsservercore

(the python:2.7-windowsservercore image is an official python image which is base on microsoft/windowsservercore)

and in the interacive console, I got the opencv-python installed by:

pip install opencv-python

after this finished, I test the opencv-python package by:

python -c "import cv2"

but I got the following error:

Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Python\lib\site-packages\cv2\__init__.py", line 9, in <module> from .cv2 import * ImportError: DLL load failed: The specified module could not be found.

then I installed python-2.7.13 on the host(not inside container), input the same pip install commands, and test python -c "import cv2" again, it won't report any error. I wonder if there are some DLL files are missing in the container? What package or software should I install in the container to fix this error?

2

There are 2 answers

1
norlesh On

Based on the accepted answer to this question I would put my money on you not having the required MSVC runtime. Assuming it was compiled with Visual Studio 2015 the runtime can be downloaded from Visual C++ Redistributable for Visual Studio 2015

0
vdsbenoit On

I found the solution in this place.

Copy the following files from your host into your container's \System32 folder:

  • msacm32.dll
  • avifil32.dll
  • avicap32.dll
  • msvfw32.dll