1,镜像源
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣:http://pypi.douban.com/simple/
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/simple/
2,临时使用镜像源安装
pip install -i http://pypi.douban.com/simple/ numpy
pip install -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com # 此参数“--trusted-host”表示信任,如果上一个提示不受信任,就使用这个
# pip install -i 国内镜像源地址 包名
3,永久配置镜像源
Windows 系统
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
# pip config set global.index-url 国内镜像源地址
Linux 系统
# 1,打开终端
mkdir /root/.pip
# 2,如果提示目录不存在,自行创建一个(如果目录存在,可跳过此步)
touch /root/.pip/pip.conf
# 3,vim编辑文件
vim pip.conf
# 4,输入下面的内容 这里用的是清华大学的源 也可以换成其他的
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn # trusted-host 此参数是为了避免麻烦,否则使用的时候可能会提示不受信任
# 5,输入完毕 按esc 保存退出
:wq!