Could not find a version that satisfies the requirement 安装包名字 (from versions: ) 最终解决方案!!

大家在刚开始使用python 时会遇到缺少python 库的问题,提示 No module named ’ 安装包名字’ 问题

在解决安装包问题中在网上找了很多的方法,方法很多各种各样,对一部分人有用,对一部分没有用,下面对这些方法做了整理,希望可以节省大家查问题解决问题的时间。

这时候根据No module named ’ 安装包名字’ 百度查解决方法,方法有很多,比如

方法一:pip install 安装包名字

方法二:python -m pip install 安装包名字

方法三:pip --trusted-host pypi.python.org install 安装包名字

这时候部分人会解决,但是还是会出现新的报错
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:852)’),)’: /simple/six/
Could not fetch URL https://pypi.org/simple/six/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘pypi.org’, port=443): Max retries exceeded with url: /simple/six/ (Caused by SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:852)’),)) - skipping
Could not find a version that satisfies the requirement 安装包名字(from versions: )
No matching distribution found for 安装包名字

接着继续根据Could not find a version that satisfies the requirement 安装包名字 查问题
会提示换成国内的pip源 可以解决问题

方法一:pip install 安装包名字 -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com //豆瓣镜像网站

方法二:pip install 安装包名字 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com //豆瓣

方法三:pip install 安装包名字 -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn //清华大学

还有下面几个国内pip 源,大家可以依次按照上面的方法试下

1)http://mirrors.aliyun.com/pypi/simple/ 阿里云
2)https://pypi.mirrors.ustc.edu.cn/simple/ 中国科技大学
3) http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学

这时候也会有部分人解决了问题,下载安装成功,问题解决了的可以不用往下看了,如果还是有问题的可以继续。

方法一:再继续查,提示跟环境和版本有关,环境不支持32位的,如果是32位就换成64位的python,还有版本要在3.7 以下,降成3.6和3.5都可以,我的环境是64位的,降成3.6 版本后试了下无效,但是大家可以试下,可能有效。

方法二:也就是最终的解决办法,自己下python 库,在http://pypi.doubanio.com/simple/ 这个镜像网站中包含了所有的常见库,需要哪个就直接下载,在安装库中也会报错,这时候你需要查看pip支持的哪些符号,运行如下命令:
1、amd64:cpu是x64的,(注意并不是指操作系统是64位的)用如下代码查看
import pip._internal
print(pip._internal.pep425tags.get_supported())

2、win32:指Windows操作系统,用如下代码查看
import pip
print(pip.pep425tags.get_supported())
如果出现如下错误说明用错了命令,用上面两个命令中的另一个就行了。

命令运行成功后可以看到如下信息:
在这里插入图片描述
出现了pip支持的符号
[(‘cp36’, ‘cp36m’, ‘win_amd64’), (‘cp36’, ‘none’, ‘win_amd64’), (‘py3’, ‘none’, ‘win_amd64’), (‘cp36’, ‘none’, ‘any’), (‘cp3’, ‘none’, ‘any’), (‘py36’, ‘none’, ‘any’), (‘py3’, ‘none’, ‘any’), (‘py35’, ‘none’, ‘any’), (‘py34’, ‘none’, ‘any’), (‘py33’, ‘none’, ‘any’), (‘py32’, ‘none’, ‘any’), (‘py31’, ‘none’, ‘any’), (‘py30’, ‘none’, ‘any’)]

我们需要看我们所下载的离线文件名字符号为(‘cp36’,’cp36m’,‘win_amd64’)在不在支持的列表中。如果不在的话就会安装失败,大家下载对应pip支持符号就可以了。

下载的安装文件 执行指令pip install xxxx.whl 就可以,如果下载的是xxxx.zip 包,将包解压,把文件直接放到python 安装路径下 xxxx\Python\Python36\Lib 即可。

问题最终解决!!!

猜你喜欢

转载自blog.csdn.net/shenliu128/article/details/109399047
今日推荐