AttributeError: module ‘cv2’ has no attribute ‘ximgproc’
问题描述
安装opencv-contrib-python如下指令,报错
pip install opencv-contrib-python -i https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
原因分析:
虚拟环境下访问不到user,要改一下虚拟环境的配置
解决方案:
-
Go to the pyvenv.cfg file in the Virtual environment folder
-
Set the include-system-site-packages to true and save the change
-
Reactivate the virtual environment.
安装opencv-contrib-python后依旧报错:AttributeError: module ‘cv2.cv2’ has no attribute ‘ximgproc’
原因分析:
问题发生的原因很有可能是电脑上除了opencv-contrib-python之外还有别的opencv包.
解决方案
把和opencv有关的库全部删了,就留一个opencv-contrib-python。opencv-contrib-python 和 opencv-python 是包含关系,不能同时存在