今天更新pip时,一直报错。
ERROR: Exception:
Traceback (most recent call last)
检查了下,下载源默认为:
Downloading https://files.pythonhosted.org/packages/5a/4a/39400ff9b36e719bdf8f31c99fe1
fa7842a42fa77432e584f707a5080063/pip-20.2.2-py2.py3-none-any.whl
默认国外下载源,慢的要炸!!还老是出现超时错误!!
为了安装成功,必须要换下载源!!
国内下载源推荐:
-
国内源
1
2
3
4
5
6
7
8
9
10
11
清华: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.sdutlinux.org/
指定下载源使用 “-i”选项指定(一次性):
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple
例如:pip install SomePackage -i https://pypi.tuna.tsinghua.edu.cn/simple
这样就会从清华这边的镜像库中去查找安装SomePackage库。
永久修改下载源地址:
修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url 为国内镜像地址,内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
下来重启CMD。
执行更新pip。
python -m pip install -U pip
完美更新成功!