关于Anaconda中opencv-python的安装

首先,尝试用pip进行安装

(base) D:\Anaconda3\Lib>pip install opencv-python -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
Looking in indexes: http://pypi.douban.com/simple/
Collecting opencv-python
  Downloading http://pypi.doubanio.com/packages/01/9b/be08992293fb21faf35ab98e06924d7407fcfca89d89c5de65442631556a/opencv-python-4.5.3.56.tar.gz (89.2MB)
    100% |████████████████████████████████| 89.2MB 3.1MB/s
  Could not find a version that satisfies the requirement numpy==1.13.3 (from versions: )
No matching distribution found for numpy==1.13.3
You are using pip version 10.0.1, however version 21.2.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

就算用豆瓣源,也还总是报错,报错原因大概是numpy版本不符合???
接着我将(base)环境中的numpy重装了,仍然没有解决

此时,打开官网/清华镜像,去寻找opencv-python的python38版本
关于Anaconda中opencv-python的安装_第1张图片
显然,选择最下面一个进行下载

下载结束后将文件放在 .\Anaconda3\Scripts 里边

然后打开cmd,输入activate进入(base)环境,用pip进行安装

pip install "D:\Anaconda3\Scripts\opencv_python-4.5.3-cp38-cp38-win_amd64.whl"

此时 报错

Requirement 'D:\\Anaconda3\\Scripts\\opencv_python-4.5.3-cp38-cp38-win_amd64.whl' looks like a filename, but the file does not exist
opencv_python-4.5.3-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.

参考

https://www.cnblogs.com/ruoli-s/p/14204897.html

打开python后 输入

>>> import pip._internal
>>> print(pip._internal.pep425tags.get_supported())
[('cp38', 'cp38m', 'win_amd64'), ('cp38', 'none', 'win_amd64'), ('py3', 'none', 'win_amd64'), ('cp38', 'none', 'any'), ('cp3', 'none', 'any'), ('py38', 'none', 'any'), ('py3', 'none', 'any'), ('py37', 'none', 'any'), ('py36', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]

可以看到,我们的文件名"cp38-cp38-win_amd64"并不能识别,故改为"cp38-cp38m-win_amd64"

再次执行

pip install "D:\Anaconda3\Scripts\opencv_python-4.5.3-cp38-cp38m-win_amd64.whl"

终于看到了

Installing collected packages: opencv-python
Successfully installed opencv-python-4.5.3

你可能感兴趣的:(踩坑,pip)