pyinstaller打包错误:ERROR: recursion is detected during loading of “cv2“ binary extensions.

ImportError: ERROR: recursion is detected during loading of “cv2” binary extensions. Check OpenCV installation.

在尝试使用python包pyinstaller将.py文件打包时,遇见下面ERROR。

具体的错误和结局方法如下。

程序报错

recursion is detected during loading of “cv2“ binary extensions.”

Traceback (most recent call last):
  File "Sy.py", line 15, in 
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "cv2\__init__.py", line 180, in 
    bootstrap()
  File "cv2\__init__.py", line 152, in bootstrap
    native_module = importlib.import_module("cv2")
  File "importlib\__init__.py", line 126, in import_module
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "cv2\__init__.py", line 180, in 
    bootstrap()
  File "cv2\__init__.py", line 75, in bootstrap
    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.

解决办法

降低cv2版本。

本人使用环境:python=3.6.12,pyintaller=4.7

pyinstaller和cv2版本存在兼容问题,卸载已有的opencv-python,安装opencv-python=4.5.3.56

再执行打包命令,完美运行。

网上还有其他方法解决此问题。

references

ImportError: ERROR: recursion is detected during loading of “cv2” binary extensions. Check OpenCV installation. - 走看看 (zoukankan.com)

你可能感兴趣的:(个人记录,python,opencv,开发语言)