Skip to content

opencv-python-headless depends on windows media feature pack after 4.7 update #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
matteoaletti opened this issue Jan 9, 2023 · 9 comments
Assignees

Comments

@matteoaletti
Copy link

Expected behaviour

On previous version (4.6.0.66) of opencv-python-headless, the package did not depend on windows media feature pack.

>> pyi-bindepend.exe "C:\Users\user\anaconda3\envs\cv246\Lib\site-packages\cv2\cv2.pyd"
C:\Users\user\anaconda3\envs\cv246\Lib\site-packages\cv2\cv2.pyd {'WSOCK32.dll', 'ole32.dll', 'KERNEL32.dll', 'OLEAUT32.dll', 'python3.dll'}

Actual behaviour

More recently (4.7.0.68) of opencv-python-headless, the package depends on windows media feature pack that is not available in windows docker image (windows/servercore:ltsc2019) .

>> pyi-bindepend.exe "C:\Users\user\anaconda3\envs\cv247\Lib\site-packages\cv2\cv2.pyd"
C:\Users\user\anaconda3\envs\cv247\Lib\site-packages\cv2\cv2.pyd {'MFReadWrite.dll', 'MF.dll', 'MFPlat.DLL', 'OLEAUT32.dll', 'KERNEL32.dll', 'SHLWAPI.dll', 'ole32.dll', 'WSOCK32.dll', 'python3.dll'}

Steps to reproduce

I have installed opencv-python-headless in a conda python 3.9 environment with

pip install opencv-python-headless

@asmorkalov asmorkalov self-assigned this Jan 10, 2023
@asmorkalov
Copy link
Collaborator

@matteoaletti Thanks for the issue report. I have not found explicit changes in setup.py or build scripts that manage Media Foundation dependency. Looks like it's some side effect of Python 3.6 -> 3.7 or Github actions environment update. Could you list other container specific issues here. I want to discuss the next steps with colleagues.

@matteoaletti
Copy link
Author

Thank you for your answer.

I am not sure that there are any other container specific issues. We are using a conda environment with python 3.9 inside a windows docker container (windows/servercore:ltsc2019) and when we use the opencv-python-headless 4.6.0.66 we can import cv2. Same environment with version 4.7.0.68 and our tests produces an error during the import of cv2:

ImportError: DLL load failed while importing cv2: The specified module could not be found

We tried to debug it ourselves and found out the new DLL dependencies mentioned above.
Everything works fine outside the container in a normal windows OS where those libraries are available.

For now, we simply pinned the version to the latest 4.6.

@alalek
Copy link
Member

alalek commented Jan 10, 2023

@asmorkalov Need to check G-API module and/or obsensor feature.

@yoonjs2
Copy link

yoonjs2 commented Nov 1, 2023

Any news to resolve this issue after 4.8 version? I encountered this issue when import cv2 in aws codebuild docker container image (windows server 2019) . I tried 4.6 4.7 4.8 but only 4.6 works.

@asmorkalov
Copy link
Collaborator

Decided to switch to plugins for videoio in headless package on Windows. In case of good luck, it'll be part of 4.9.0.x.

@matteoaletti
Copy link
Author

matteoaletti commented Jan 8, 2024

@asmorkalov I see that a new release of opencv is out, was this switch included in 4.9.0.80 ?

I still see the same dependencies (and errors) as for versions 4.7 and 4.8

@Avasam
Copy link

Avasam commented Aug 1, 2024

Likely duplicated by #856 (although that issue is more popular)

@pwuertz
Copy link

pwuertz commented Apr 29, 2025

The current opencv-python-headless 4.11 package still depends on Media Foundation Platform libraries:

pyi-bindepend cv2.pyd
  KERNEL32.dll => C:\Windows\system32\KERNEL32.dll
  MF.dll => C:\Windows\system32\MF.dll
  MFPlat.DLL => C:\Windows\system32\MFPlat.DLL
  MFReadWrite.dll => C:\Windows\system32\MFReadWrite.dll
  OLEAUT32.dll => C:\Windows\system32\OLEAUT32.dll
  SHLWAPI.dll => C:\Windows\system32\SHLWAPI.dll
  WSOCK32.dll => C:\Windows\system32\WSOCK32.dll
  ole32.dll => C:\Windows\system32\ole32.dll
  python3.dll => C:\ProgramData\scoop\apps\python\current\python3.dll

Importing the cv2 module remains unsupported within Windows Server Core containers or Windows N systems, where Media Foundation is not available.

However, the Media Foundation libraries are present in the mcr.microsoft.com/windows/server:ltsc2025 Docker image. If you are currently blocked by this issue, switching to that base image may be a viable workaround. In my testing, importing cv2 succeeds in this environment (though I haven't yet validated more complex functionality).

@asmorkalov
Copy link
Collaborator

Related ticket: #263
Will try to make MSMF plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants