0%

[Python] 更换国内pip源

一次性使用

可以在使用pip的时候加参数: -i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install SomePackage -i https://pypi.tuna.tsinghua.edu.cn/simple
这样就会从清华这边的镜像去安装SomePackage库。

永久修改,一劳永逸:

  • linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url 为国内镜像地址,内容如下:
1
2
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
  • windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini,内容如下
1
2
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

原文链接:https://blog.csdn.net/qq_14994573/article/details/80934201

欢迎关注我的其它发布渠道