常见源的地址
# 阿里云
https://mirrors.aliyun.com/pypi/simple/
# 豆瓣
http://pypi.douban.com/simple/
# 清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
# 中国科学技术大学
http://pypi.mirrors.ustc.edu.cn/simple/
# 华中科技大学
http://pypi.hustunique.com/
一、windows下换源
1.修改文件换源
此路径下创建文件 C:\Users\用户名\pip\pip.ini ,内容如下
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = https://mirrors.aliyun.com/pypi/simple/
ps:镜像源为 http 的路径不用加 trusted-host 选项,https 的话要加
二、linux下换源
1.修改文件换源
此路径下创建文件 ~/.config/pip/pip.conf ,内容如下
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = http://mirrors.aliyun.com/pypi/simple/
ps:镜像源为 https 的路径不用加 trusted-host 选项,http 的话要加
2.命令方式换源
# python -m pip install -U pip
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
pip config set install.trusted-host https://mirrors.aliyun.com/pypi/simple/
ps:
- python -m pip install -U pip:顺手更新一下 pip
最后,如果是windows的话,最好再修改一下pip的默认缓存路径,可以参考这篇文章https://blog.csdn.net/weixin_43721000/article/details/127902446