Pycharm,Python 安装OpenCV and CV2 时,报错,教你如何正确安装。

报错信息
Collecting cv2
Could not find a version that satisfies the requirement cv2 (from versions: )
No matching distribution found for cv2

初学Python,在安装cv2框架的时候,报以上错误,试了很多次 pip install cv2 依然无效,后来查阅了好多资料,总结下面的方法,安装了opencv后,里面包含了cv2框架。

If you are using python 2 you can install with pip:

pip install opencv-python

Or use the equivilent for python 3:

pip3 install opencv-python

``windows下面
PS D:\迅雷下载> pip install opencv_python-4.2.0.32-cp36-cp36m-win_amd64.whl
Processing d:\迅雷下载\opencv_python-4.2.0.32-cp36-cp36m-win_amd64.whl
Collecting numpy>=1.11.3
  Downloading numpy-1.18.2-cp36-cp36m-win_amd64.whl (12.8 MB)
     |████▌                           | 1.7 MB 3.5 kB/s eta 0:52:30


PS D:\迅雷下载> pip install numpy-1.18.2-cp36-cp36m-win_amd64.whl
Processing d:\迅雷下载\numpy-1.18.2-cp36-cp36m-win_amd64.whl
Installing collected packages: numpy
Successfully installed numpy-1.18.2

Processing d:\迅雷下载\opencv_python-4.2.0.32-cp36-cp36m-win_amd64.whl
Requirement already satisfied: numpy>=1.11.3 in c:\users\administrator\appdata\local\programs\python\python36\lib\site-packages (from opencv-python==4.2.0.32) (1.18.2)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.2.0.32


PS E:\CV> python cv_3.py
Traceback (most recent call last):
  File "cv_3.py", line 1, in 
    from PIL import Image, ImageDraw, ImageFont
ModuleNotFoundError: No module named 'PIL'
PS E:\CV> pip install PIL
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: No matching distribution found for PIL

PS E:\CV> pip install Pillow
Collecting Pillow
  Downloading Pillow-7.0.0-cp36-cp36m-win_amd64.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 4.8 kB/s
Installing collected packages: Pillow
Successfully installed Pillow-7.0.0
安装完成即可解决无法引入PIL的问题。

你可能感兴趣的:(python,python)