python pip anaconda conda 切换国内源(清华镜像)

 

anaconda配置镜像

Mac and Linux

1
2
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

 Windows

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

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

 

pip配置镜像 

Linux

修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:

 

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

 请注意:一定是在你个人用户文件夹下先建立pip文件夹,在建立pip.ini文件,不是直接把pip.ini文件放在C:\Users\xx\下

 

pip临时镜像

 

临时使用:

 

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

 

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

当遇到pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='pypi.tuna.tsinghua.edu.cn', port=443): Read timed out.

 

 

 比如我使用   :easy_install pip  就会出现这个超时,建议更换成豆瓣源使用   -i https://pypi.doubanio.com/simple