在一个新环境上使用 import cv2 时,报错,找不到包,于是就用 PyCharm 安装 cv2(install package cv2),然后接着报错:Collecting cv2 Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2,发现最后用pip重新安装。
Python 版本:Python 3
在 PyCharm 上 import cv2 时,提示找不到 cv2,快捷键 option + return
选择解决方案“install package cv2”,最后提示错误如下:
Collecting cv2 Could not find a version that satisfies the requirement cv2 (from versions: ) No matching distribution found for cv2
同样的,在 install opencv 时,报错如下:
Collecting opencv Could not find a version that satisfies the requirement opencv (from versions: ) No matching distribution found for opencv
其实这个问题的原因很简单,cv2 和 opencv 并不是包名,它俩都是 opencv-python 的一部分,直接安装 opencv-python就解决了。
如果你在用 Python2:
pip install opencv-python
如果你在用 Python3:
pip3 install opencv-python