zoukankan      html  css  js  c++  java
  • ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.

     问题:

    pyinstaller 打包后,运行生成的exe报错 “recursion is detected during loading of “cv2“ binary extensions.”

    Traceback (most recent call last):
      File "Sy.py", line 15, in <module>
      File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
      File "cv2\__init__.py", line 180, in <module>
        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 <module>
        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.

    ========================

    使用pip卸载opencv,pip uninstall opencv*******(具体的安装的opencv的名字)
    到%:\python\Lib\site-packages%路径(安装的python的路径)下删除cv2的文件夹
    再用pip重新安装opencv,pip install opencv****

    ========================

    解决方法(可依次尝试):

    1.重装cv2。(这是回答比较多的,多数情况有用)

    先pip unintall opencv-python ,再pip intall opencv-python

    2.设置环境变量。

    参考:

    Python-Opencv [ERROR: recursion is detected during loading of "cv2"_凌空的桨-CSDN博客

    3.降低cv2版本。

    pyinstaller和cv2的版本存在兼容问题。本人用的pyinstaller是4.7(python3.8.0),cv2是4.5.4.58,结果出错,把cv2版本降低到4.5.1.48再打包,就不报错了。

    ========================

    https://wiki.archlinux.org/index.php/Arch_Linux_Archive#How_to_downgrade_one_package

    ========================

    open cmd and use pip to install a different version:

     pip install opencv-python==4.5.3.56
    

    ========================

    opencv-python      4.5.5.62

    ========================

    REF

    https://blog.csdn.net/weixin_44205803/article/details/100975762

    https://blog.csdn.net/qq_44796370/article/details/121458744

  • 相关阅读:
    c# Invalidate() Update() Refresh()的区别
    Winform重画ComboBox背景色
    窗口过程 Wndproc
    设置DatagridView的列头样式
    SQL2005 全文检索超时的解决方案
    winform 获取当前程序运行根目录
    Web API-如何将Controller的返回值转换成HTTP response消息
    ASP.NET Web API 如何通过程序控制返回xml还是json
    C# web api返回类型设置为json的两种方法
    多组 RadioButtonList 获取值
  • 原文地址:https://www.cnblogs.com/emanlee/p/15831194.html
Copyright © 2011-2022 走看看