目录
linux更改pip源
永久使用
一次使用
windows更改pip源
linux更改pip源
可供使用的几个常用的国内源
清华:https://pypi.tuna.tsinghua.edu.cn/simple
中科大:https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣:http://pypi.douban.com/simple/
设置时可以设置一次性使用和永久使用
永久使用
修改 /root目录下 ~/.pip/pip.conf(没有就创建一个), 修改 index-url 为国内镜像地址,以清华地址为例:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
保存退出,再利用pip下载
一次使用
可以在使用pip的时候加参数 -i https://pypi.tuna.tsinghua.edu.cn/simple
例: pip install Package -i https://pypi.tuna.tsinghua.edu.cn/simple
windows更改pip源
-
找到系统盘下C:\C:\Users\用户名\AppData\Roaming,APPData可能是隐藏文件,需要将隐藏关闭; -
查看在Roaming文件夹下有没有一个pip文件夹,如果没有创建一个; -
进入pip文件夹,创建一个pip.ini文件; -
使用记事本的方式打开pip.ini文件,写入:
[global]
timeout = 6000 # 设置超时
index-url = https://pypi.tuna.tsinghua.edu.cn/simple # 指定下载源
trusted-host = pypi.tuna.tsinghua.edu.cn # 指定域名
|