python
主页 > 脚本 > python >

Python pip更换镜像源的步骤

2024-12-02 | 佚名 | 点击:

1.1 默认镜像,速度慢,易报错

1.2 常用国内镜像源

镜像 网址
中科大 https://pypi.mirrors.ustc.edu.cn/simple/
清华 https://pypi.tuna.tsinghua.edu.cn/simple/
豆瓣 http://pypi.douban.com/simple/
阿里 https://mirrors.aliyun.com/pypi/
上交大 https://mirror.sjtu.edu.cn/pypi/web/simple/

2 更改镜像源

2.1 临时更改

1

2

3

4

5

# 命令格式

pip install <安装包> -i <镜像源>

 

# 如:用中科大的镜像源安装 python-docx

pip install python-docx -i https://pypi.mirrors.ustc.edu.cn/simple

2.2 永久更改

2.2.1 查看配置源及配置文件

1

2

3

4

5

# 查看 pip 配置

pip config list

 

# 查看 pip 配置文件的路径

pip config -v list

2.2.2 编辑 pip.ini

1

2

3

4

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple/

[install]

trusted-host = pypi.tuna.tsinghua.edu.cn

2.2.3 配置后的效果

原文链接:
相关文章
最新更新