由于网络有时不稳定的原因,使用pip/pip3下载会出现网络不可达的问题。建议修改pip源,使用国内镜像服务。
两种方式,一种是一次性的,一种是永久性的。
话不多说、直接开干~
1、常用pip国内源镜像如下:
pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
永久性设置,是在用户根目录(~,而非系统根目录 / )下添加配置~/.pip/pip.conf目录添加可信源,如果目录文件不存在,可直接创建。
比如root用户
[root@localhost ~]# cd ~
[root@localhost ~]# mkdir .pip
[root@localhost ~]# cd .pip
[root@localhost .pip]# vim pip.conf
设置pip源
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn