解决报错cannot import name ‘

解决报错cannot import name ‘,第1张

解决报错cannot import name ‘_registerMatType‘ from ‘cv2.cv2‘
使用yolox时系统运行报这个错误

Traceback (most recent call last):
  File "tools/train.py", line 13, in <module>
    from yolox.core import Trainer, launch
  File "/user-data/YOLOX-main/yolox/__init__.py", line 4, in <module>
    from .utils import configure_module
  File "/user-data/YOLOX-main/yolox/utils/__init__.py", line 15, in <module>
    from .setup_env import *
  File "/user-data/YOLOX-main/yolox/utils/setup_env.py", line 9, in <module>
    import cv2
  File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 9, in <module>
    from .cv2 import _registerMatType
ImportError: cannot import name '_registerMatType' from 'cv2.cv2' (/opt/conda/lib/python3.8/site-packages/cv2/cv2.cpython-38-x86_64-linux-gnu.so)

解决方法:
如果在notebook中执行以下命令

!pip uninstall opencv-python-headless
!pip install opencv-python-headless==4.1.2.30

如果在pycharm或者服务器上,执行以下命令

pip uninstall opencv-python-headless
pip install opencv-python-headless==4.1.2.30

如果有帮助请在评论区反馈
参考自stack overflow https://stackoverflow.com/questions/70537488/cannot-import-name-registermattype-from-cv2-cv2

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/943786.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-18
下一篇 2022-05-18

发表评论

登录后才能评论

评论列表(0条)

保存