Update python pip source to domestic mirror on different platforms

I installed flask once and used the python default source, because of resource acquisition and network reasons, various time out errors, such as: raise ReadTimeoutError (self._pool, None, 'Read timed out.')

It was found that the network was too slow to load the file and caused an error, so I found some ways to update the pip source to the country, once and for all.

Domestic pip source address:

1、豆瓣(douban):http://pypi.douban.com/simple/ 

2、清华大学:https://pypi.tuna.tsinghua.edu.cn/simple/

3、阿里云:http://mirrors.aliyun.com/pypi/simple/

4、中国科技大学:https://pypi.mirrors.ustc.edu.cn/simple/

5、中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/simple/

6、华中理工大学:http://pypi.hustunique.com/

7、山东理工大学:http://pypi.sdutlinux.org/

Temporary use of domestic sources:

pip install -i 国内源地址  需要安装的包名

如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple flask

First, the method of permanently updating to domestic pip source under linux

#创建文件、地址
mkdir ~/.pip/              
cd ~/.pip/

#编辑文件
vi pip.conf  #输入一下内容(以清华源为例)
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

#更新pip(非必须)
pip3 install --upgrade pip

#直接使用国内源安装,和默认源用法一致,如:
pip3 install flask

Second, the method of updating the pip source under the windows platform

#在当前登录用户(这里以默认administrator为例)路径下进行以下操作

#进入C盘Users\\Administrator路径下创建pip目录,在pip目录下创建pip.ini文件

#编辑文件pip.ini文件内容与linux一致,如:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn

#保存文件,更新pip后默认命令使用即可,如:
pip install flask

Third, the pycharm editor updates the pip source

#pycharm使用方法
#在pycharm的
File >Settings > Project: 你的工程名 > Project Interpreter 右边加号

#然后点Manager Repositories
#输入下面的镜像地址

https://pypi.tuna.tsinghua.edu.cn/simple/

#点击OK确定输入
#重启编辑器后就可以直接获取源包列表,选择需要的直接安装即可

 

Published 59 original articles · 69 praises · 270,000+ views

Guess you like

Origin blog.csdn.net/pansaky/article/details/104907159