After python nuitka has packaged the program and moved the cv2 library file to the program directory, it can be run in the python environment. After leaving the python environment, it will prompt: ImportError: DLL load failed while importing cv2: cannot find the specifiedmodule.
1 . Because my program can run in the python environment, it means that the cv2 in my environment can be used normally.
2. The packaged program can be run in the python virtual environment, indicating that the packaged program has no problem.
3. After the packaged program leaves the python virtual environment, it prompts that the cv2 module cannot be found, indicating that it is caused by the cv2 import package.
Therefore, I just need to solve the exception problem after cv2 introduces the package.
pip uninstall opencv-pythonpip uninstall opencv-contrib-pythonpip install opencv-pythonpip install opencv-contrib-python
Configure in IDEA Add the directory where cv2 is located to the environment variable
Use Dependency Walker to check for missing dll dependencies in file cv2.pyd
in cv2, to reimport.
Modify the pyd
file name in the cv2 folder to cv2.pyd
Because I need to package it and provide it to others as an independent program, it is not suitable for my application scenario.
Since the methods provided by netizens are not applicable, you can only find methods according to your own scenarios.
There is no problem in using cv2 in the python environment where the program is located. If I use cv2 in the environment directly, it should be able to solve my problem.
Through pycharm, I open cv2.__init__.py
and jump to .cv2
again.
Note that in the python virtual environment where the program runs, the jump is successful, cv2.cv2.__init__.py
is opened, and the cv2 library of time isThere is no such file.
Open cv2.cv2.__init__.pyThe directory where
is located, which does not exist under the cv2 folder.Compare the differences between the cv2 folder used in the program operation and the files in the cv2 library file directory.