python
安装好 python 后,环境变量也设好了,就可以开始相应的设置
pip
官方文档:https://pip.pypa.io/en/stable/cli/pip/
换源
设为默认
-
通过指令设置 pip 全局镜像源
# 升级 pip 版本 (>=10.0.0) $ pip install -i https://mirrors.cloud.tencent.com/pypi/simple --upgrade pip # 设置源地址 $ pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple
-
也可以手动在 pip 的配置文件中添加全局配置项
配置文件(没有就手动创建)
- 在 Windows 下是
C:\Users\{username}\AppData\Roaming\pip\pip.ini
- 在 Linux 下是
~/.pip/pip.conf
配置条目如下:
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
- 在 Windows 下是
列举一下源地址:
- 阿里云 http://mirrors.aliyun.com/pypi/simple
- 腾讯云 https://mirrors.cloud.tencent.com/pypi/simple
- 清华 https://pypi.tuna.tsinghua.edu.cn/simple
- 中科大 https://pypi.mirrors.ustc.edu.cn/simple
- 豆瓣 http://pypi.douban.com/simple
临时换源
在 pip 安装时指定源地址
$ pip