解决 Could not find a version that satisfies the requirement xxx

在 Ubuntu 22 下为 python 2.7 安装 numpy、opencv 时的报错记录

电脑上的 Ubuntu 版本是 22.04.1,因为工作需要用到 python2,而 Python 2 已经从 ubuntu20.04 中移除了,于是手动安装了 python 2.7.18;又手动下载了 pip,版本是 20.3.4

为python2.7安装pip时是参考了:u20安装pip2Ubuntu 20已经无法通过apt来安装python2的pip2了,只能安装python3的pip。方法先确保你有python2# 暂时还是可以用apt安装python2sudo apt install python2# 下面这个链接可能会失效,不过会提示你去新的链接下载,把链接换了就可以。wget https://bootstrap.pypa.io/pip/2.7/get-pip.pysudo python2 get-pip.py接下来你就可以用指定的python pihttps://blog.csdn.net/BAIFOL/article/details/122661042

从 https://www.python.org/downloads/ 下载的 python 安装之后是有带pip安装包的,安装目录下/lib/python2.7/ensurepip/_bundled/ 下面有 pip-19.2.3-py2.py3-none-any.whl,pip install xxxx.whl可以安装对应安装包,不过没有试过当前环境下这样安装能不能用

不知道是不是因为这一顿操作导致版本不匹配还是怎样,使用pip install numpy命令时会提示:

ERROR: Could not find a version that satisfies the requirement numpy (from versions: none)
ERROR: No matching distribution found for numpy found for numpy

此时使用命令pip -vvv install numpy可以安装numpy,安装下来的版本为1.16.6

Successfully installed numpy-1.16.6

使用pip install opencv命令时会提示:

ERROR: Could not find a version that satisfies the requirement opencv (from versions: none)
ERROR: No matching distribution found for numpy found for opencv

此时使用命令pip install opencv-python==3.2.0.8可以安装

(4.2.0.32是最新一个可支持python2.7的版本。可以根据需要安装对应的opencv版本)

物联沃分享整理
物联沃-IOTWORD物联网 » 解决 Could not find a version that satisfies the requirement xxx

发表评论