question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing configuration file | OpenCV

See original GitHub issue

last factory Nuitka, win11, python 3.9.9 and 3.10.1 OpenCV: 3.4.17.61

command: python -m nuitka --windows-uac-admin --mingw64 --enable-plugin=anti-bloat --lto=no --onefile --plugin-enable=numpy "D:\Test.py"

Code: import cv2

Test.exe

Traceback (most recent call last):
  File "C:\Users\test\AppData\Local\Temp\ON6B4C~1\Test.py", line 1, in <module>
  File "C:\Users\test\AppData\Local\Temp\ON6B4C~1\cv2\__init__.py", line 118, in <module cv2>
  File "C:\Users\test\AppData\Local\Temp\ON6B4C~1\cv2\__init__.py", line 66, in bootstrap
  File "C:\Users\test\AppData\Local\Temp\ON6B4C~1\cv2\__init__.py", line 64, in load_first_config
ImportError: OpenCV loader: missing configuration file: ['config.py']. Check OpenCV installation.

I tried add: --include-data-file=D:/TEST/Lib/site-packages/cv2/config.py=cv2 --include-data-file=D:/TEST/Lib/site-packages/cv2/config-3.py=cv2

test.exe

  File "C:\Users\test\AppData\Local\Temp\ONA816~1\Test.py", line 1, in <module>
    import cv2
  File "C:\Users\test\AppData\Local\Temp\ONA816~1\cv2\__init__.py", line 118, in <module cv2>
  File "C:\Users\test\AppData\Local\Temp\ONA816~1\cv2\__init__.py", line 106, in bootstrap
  File "C:\Users\test\AppData\Local\Temp\ONA816~1\cv2\__init__.py", line 118, in <module cv2>
  File "C:\Users\test\AppData\Local\Temp\ONA816~1\cv2\__init__.py", line 31, in bootstrap
ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
junbaibai0719commented, Apr 22, 2022

I replaced

    py_module = sys.modules.pop("cv2")
    native_module = importlib.import_module("cv2")
    sys.modules["cv2"] = py_module

with:

def __bootstrap__():
   global __bootstrap__, __loader__, __file__
   import sys, pkg_resources, imp
   __file__ = pkg_resources.resource_filename(__name__,'cv2.cpython-310-x86_64-linux-gnu.so')
   print(__file__)
   __loader__ = None; del __bootstrap__, __loader__
   return imp.load_dynamic(__name__,__file__)

def bootstrap():
   [...]
   py_module = sys.modules.pop("cv2")
   native_module = __bootstrap__()
   sys.modules["cv2"] = py_module

Then I just needed to move the shared lib to the dist folder and it worked

In Windows,

def __bootstrap__():
   import imp
   return imp.load_dynamic(__name__,"cv2.pyd")
1reaction
kayhayencommented, Jan 9, 2022

Just checked, cv2 is also not working on Linux.

Read more comments on GitHub >

github_iconTop Results From Across the Web

OpenCV loader: missing configuration file: ['config.py'] #14064
OpenCV loader: missing configuration file: ['config.py'] #14064 ... But when I try to run the binary file, it prompted as follow:.
Read more >
[pyinstaller][open-cv] ImportError: OpenCV loader: missing ...
I am trying to build binary package of my code, the build process completed with success, but when I m trying to run...
Read more >
Missing config-3.py and config-3.8.py during installation from ...
I'm messing up when trying to install openCV from sources. System: Ubuntu 18.04 OpenCV Version: 4.5.2 (latest) Python: Python 3.8 and 3.9 (via ......
Read more >
OpenCV loader: missing configuration file: ['config.py']. Check ...
I'm trying to binarize my python application on Jetson Nano, Jetpack 4.2.1 using pyinstaller. But when run the binary file, I got this...
Read more >
Missing config-3.8.py after source build [Question] : r/opencv
Check OpenCV installation.'.format(fnames)) ImportError: OpenCV loader: missing configuration file: ['config-3.8.py', 'config-3.py ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found