Skip to content
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

Executables with opencv-python>=4.5.4 fail #1275

Closed
JJReyka opened this issue Nov 4, 2021 · 1 comment · Fixed by #1278
Closed

Executables with opencv-python>=4.5.4 fail #1275

JJReyka opened this issue Nov 4, 2021 · 1 comment · Fixed by #1278

Comments

@JJReyka
Copy link
Contributor

JJReyka commented Nov 4, 2021

Describe the bug
After building an executable which depends on the latest (4.5.4) version of opencv-python, this error ocurrs on running:

ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.

When comparing the lib/cv2 folder produced by cx_Freeze to lib/site-packages/cv2 in a python environment, the files config.py and config-{python_version}.py (config-3.8.py in my case) are missing.

From this issue, it seems that recent updates to opencv-python have made it more difficult for tools to infer what files are required. Adding the following to hooks.py makes things work, but I don't know enough about cx_Freeze to say whether this does things in the right way, or even if it works beyond my machine.

def load_cv2(finder: ModuleFinder, module: Module) -> None:
    """The cv2 module requires additional configuration files"""
    dest_dir = Path("lib", "cv2")
    cv2_dir = module.path[0]
    for path in cv2_dir.glob("config*.py"):
        finder.IncludeFiles(path, dest_dir / path.name)

To Reproduce
This bug is present for any application build with opencv-python>=4.5.4 as a dependency.

Expected behavior
I expected things to work the same as when I was using version 4.5.3

Desktop (please complete the following information):

  • Platform information (e.g. Ubuntu Linux 16.04): Windows 10
  • OS architecture (e.g. amd64): amd64
  • cx_Freeze version [e.g. 6.6]: 6.8.1
  • Python version [e.g. 3.9]: 3.8
@marcelotduarte
Copy link
Owner

marcelotduarte commented Nov 4, 2021

Can you make a PR?
And can you test the hook with opencv-python 4.5.3 to check if it doesn't break previous versions?

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

Successfully merging a pull request may close this issue.

2 participants