python pip无法安装软件包 windows环境下 报错Could not find a version that satisfies the requ

427 阅读1分钟

python pip无法安装软件包 windows环境下 报错Could not find a version that satisfies the requirement ...

报错提示一下内容:

ecd7ed0867c8bcd1c506174e5cab35d.png

分析原因

  • 由于python 的默认下载镜像对于国内的不是很友好,所有要更改python 的下载镜像为国内的。

解决办法1 --单次:

# 以安装pygame 为例
 pip install pygame -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com

解决办法2 --永久:

  1. 找到C盘 用户/用户名/AppData/Roaming/pip/pip.ini配置文件
  • 注意:AppData 是一个隐藏文件,需要打开查看选项下的显示隐藏文件,才能看到 2.打开pip.ini文件,把里面的镜像下载地址修改为以下内容:
[global]
index-url=http://mirrors.aliyun.com/pypi/simple
[install]
trusted-host=mirrors.aliyun.com
  • 注意:这里我使用的是阿里云的镜像。如想用其他的国内镜像,参考以下国内开源镜像:
清华:https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 :https://pypi.mirrors.ustc.edu.cn/simple/
华中科技大学:http://pypi.hustunique.com/
豆瓣:http://pypi.douban.com/simple/