更换pip源到国内镜像

pip国内的一些镜像

python国内源

阿里云 https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

修改源

临时使用:
可以在使用pip的时候在后面加上-i参数,指定pip源为国内源

eg: pip install scrapy -i https://pypi.tuna.tsinghua.edu.cn/simple

永久修改:
Linux/macOS:
修改 `~/.pip/pip.conf` (没有就创建一个), 内容如下:

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

对于当前用户不是`root`,而有时候需要使用`sudo`安装的情况,上述设置是无效的。需要在`root`用户目录也设置一下,一般情况下配置文件默认是`/root/.pip/pip.conf`。

Windows:
直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下

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

参考链接


更换pip源到国内镜像

发布者

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注