pyinstaller打包openCV报错

Python文件写入内容如下:

import pyautogui
import cv2

打包 目标.exe:pyinstaller -F 目标.py
运行 目标.exe ,报错:

raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')                                                                                                                     ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.         [6040] Failed to execute script 'test' due to unhandled exception!

在windows中,cmd命令进入DOS界面:

pip list | findstr opencv
opencv-contrib-python     4.8.0.74                         
opencv-python             4.9.0.80                          opencv-python-headless    4.7.0.72

多次折腾后,发现直接运行py文件时没问题的,但如果要成功运行打包后的exe,只能安装一个opencv版本。如果要import pyautogui,则只能安装opencv-contrib-python 4.8.0.74 。

其余版本要删除。

pip uninstall opencv-python
pip uninstall opencv-python-headless

你可能感兴趣的:(python图像识别)