Pyinstaller Package Error: ImportError: OpenCV loader: missing configuration file: [‘config.py‘]

When writing Python today, I referenced CV2 when packaging with pyinstaller, and this error occurred:

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

 

Create a new Python file and get the path of OpenCV:

import cv2
print(cv2.__file__) 

Here I get: C:\Anaconda3\lib\site-packages\cv2\__init__.py

After you reuse pyinstaller for packaging, add the paths parameter:

pyinstaller main.py -F --paths="C:\Anaconda3\lib\site-packages\cv2"

No error reported, successful operation!

Similar Posts: