PIP两种报错解决方法

首次使用pip安装报错

1.pip版本报错

到目前为止,最新的pip应是2开头版本号,若是刚安装python的话pip版本号一般是1开头。
解决方法:
调出CMD命令窗:

python -m pip install --upgrade pip

如果报红色
ERROR:Could not find a version that…
基本上为链接网址不可用,需要使用国内的镜像源来链接:↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

2.更改镜像源

首先可以查看镜像源:
调出CMD命令窗:

pip config list

可以看到三个配置(我的已经改过成豆瓣了):
global.index-url=‘https://pypi.douban.com/simple’
global.timeout=‘6000’
global.trusted-host=‘https://pypi.douban.com/simple/’
此时需要修改上方的global.index-url和global.trusted-host为一下任意网址(两个需相同)

国内资源地址:

阿里云 http://mirrors.aliyun.com/pypi/simple/
 
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣 http://pypi.douban.com/simple
 
Python官方 https://pypi.python.org/simple/
v2ex http://pypi.v2ex.com/simple/
中国科学院 http://pypi.mirrors.opencas.cn/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
 
中国科学技术大学 [http://pypi.mirrors.ustc.edu.cn/simple/]
 
华中理工大学:[http://pypi.hustunique.com/]
 
山东理工大学:[http://pypi.sdutlinux.org/]

更改:
调出CMD命令窗:

# 全局设置镜像源地址(此例为更改为豆瓣镜像资源)
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip config set global.trusted-host https://pypi.tuna.tsinghua.edu.cn/simple

参考文章1

猜你喜欢

转载自blog.csdn.net/weixin_45830602/article/details/127064712