【笔记】更换pip镜像源

前言

更换pip镜像源

临时配置

<url>:软件源链接

清华大学:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple

<package>:模块名

1
pip install <package> -i <url>

永久配置

设置源

通过pip全局配置

<url>:软件源链接
<domain>:软件源域名

1
2
pip config set global.index-url <url>
pip config set install.trusted-host <domain>

通过修改配置文件

Windows
%UserProfile%\AppData\Roaming\pip\pip.ini
1
2
3
4
5
[global]
index-url = <url>

[install]
trusted-host = <domain>
MacOS
~/.config/pip/pip.conf
1
2
3
4
5
[global]
index-url = <url>

[install]
trusted-host = <domain>

删除源

1
2
pip config unset global.index-url
pip config unset install.trusted-host

查看配置

1
pip config list

完成

参考文献

哔哩哔哩——图灵学院教程
CSDN——宛宛心里的月亮
博客园——木头侠
CSDN——仲浩的博客
CSDN——小刘在路上
阿里云开发者社区——程序员徐师兄