Skip to content

Commit eca1447

Browse files
authored
Merge pull request #76 from miaooo0000OOOO/patch-2
Update python_pkgs.md
2 parents f5fe0f5 + 4bb7458 commit eca1447

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

docs/doc/zh/basic/python_pkgs.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,34 @@ import os
2828
os.system("pip install --upgrade 包名")
2929
```
3030

31-
32-
3331
### 方法二: 终端使用 pip 命令安装
3432

3533
使用[Linux 基础](./linux_basic.md)中介绍的终端使用方法,使用 `pip install 包名` 安装你需要的包。
3634

35+
## pip换源
36+
37+
在使用 pip 下载 Python 软件包时,默认会从 [PyPI](https://pypi.org/) 下载。PyPI 是 Python 官方的软件包储存库,对于中国用户来说下载速度会很慢。
38+
39+
国内有许多 PyPI 的镜像源,从镜像源下载可以提升下载速度。
40+
41+
在终端中输入以下命令,可以从清华源更新 pip :
42+
43+
```
44+
python -m pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple --upgrade pip
45+
```
46+
47+
用以下命令将下载源设为清华源:
3748

49+
```
50+
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
51+
```
3852

53+
恢复默认源:
54+
55+
```
56+
pip config unset global.index-url
57+
```
3958

59+
参考:[清华大学开源软件镜像站 PyPI软件仓库](https://mirrors.tuna.tsinghua.edu.cn/help/pypi/)
4060

61+
你也可以自己寻找其他好用的镜像源。

0 commit comments

Comments
 (0)