Before packaging, it was OK. After upgrading pyinstaller and opencv, an error will be reported. I looked up a circle of information and found the answer on GitHub.
ImportError: OpenCV loader: missing configuration file: [‘config.py’]. Check OpenCV installation.
In
Pyinstaller 4.6
opencv Python 4.5.3.58
encountered a problem
Solution:
Solution 1
Reduce the opencv Python version to 4.5.3.56. This small version iteration actually changed something, resulting in packaging failure.
Solution 2
PS: I tried this method several times and failed
import cv2
print(cv2.__file__)
Execute these two sentences to find the path where CV2 is located:
D:\anaconda\64\lib\site-packages\cv2\cv2.cp38-win_ AMD64. PYD
this is my path
when packaging:
pyinstaller -F -w --key '12345678' --clean main.py --paths="D:\anaconda\64\lib\site-packages\cv2"
Remove the last file name from the path and keep the whole folder.
I suggest using the second scheme, because it is not constrained by the version, and this problem can be solved in a similar way in other packages in the future.
Read More:
- [Solved] cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\……
- [Solved] opencv-python: recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all‘ failed
- Opencv Python realizes the paint filling function in PS, one click filling color and the possible reasons for opencv’s frequent errors
- Opencv-python Install is Stuck Error: running setup.py bdist_wheel for opencv-python
- [Solved] OpenCV Import Error: ImportError: numpy.core.multiarray failed to import
- Raspberry pie compilation and installation opencv error: fatal error: bootdesc_bgm.i: No such file or directory
- Raspberry pie import opencv error: ImportError: numpy.core.multiarray failed to import
- [Solved] ERROR: Failed building wheel for opencv-python-headless
- [Solved] python opencv Error: findContours() Can only use the Grayscale
- Python+OpenCV: How to Use Background Subtraction Methods
- Detailed explanation of OpenCV approxpolydp() function
- How to Solve Opencv Reads Video Error: cv2.error
- Opencv: How to Draw Palette
- v2.error: OpenCV(4.5.5) error: (-215:Assertion failed) npoints > 0 in function ‘cv::drawContours‘
- [Solved] cv2.error: OpenCV(4.5.3) :-1: error: (-5:Bad argument) in function “pointPolygonTest“
- [Solved] Python opencv imshow Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow
- [Solved] cv2.error: OpenCV(4.5.1) XXX\shapedescr.cpp:315: error: (-215:Assertion failed) npoints >= 0 &&……
- [Solved] error: OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function ‘copyMakeBorder‘
- [Solved] cv2.error: OpenCV(4.5.3) :-1: error: (-5:Bad argument) in function ‘circle‘