Is Python slow to install third-party libraries? -Change the mirror address of the Python pip library

Foreword

Generally, after installing python, the default mirror address of pip is: https://pypi.org/simple. However, because the default official pypi is often blocked, or the connection speed is slow, the pip installation is often unavailable or the download of the installation package fails, so We'd better replace the pip source we use and install the source using the domestic pip image.

There are many sources available online, such as:

Tsinghua University: https://pypi.tuna.tsinghua.edu.cn/simple Tsinghua University ’s pip source is a mirror image of the official website pypi, which is synchronized every 5 minutes. It is recommended! ! !

Alibaba Cloud: http://mirrors.aliyun.com/pypi/simple/

University of Science and Technology of China https://pypi.mirrors.ustc.edu.cn/simple/

Huazhong University of Science and Technology: http://pypi.hustunique.com/

Shandong University of Technology: http://pypi.sdutlinux.org/

Douban: http://pypi.douban.com/simple/

Use mirror address temporarily

Add parameters when using pip -i https://pypi.tuna.tsinghua.edu.cn/simple

pip install [module] -i https://pypi.org/simple
pip install  -i https://pypi.org/simple -U [module]
#-U可有可无
#-U, --upgrade    Upgrade all specified packages to the newest available version. The handling of dependencies depends on the upgrade-strategy used
#将所有指定的包升级到最新的可用版本。依赖关系的处理取决于所使用的升级策略。

E.g:

#安装最新版本tensorflow
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple  -U tensorflow

Permanently modify the pip image (recommended)

Linux system:

Modify ~ / .pip / pip.conf (create a pip folder and pip.conf file without it. The folder should be added with "." To indicate a hidden folder). The content of the pip file is as follows:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

Windows system:

Create a pip directory directly in the user directory, such as:, C:\Users\xx\pipand create a new file pip.inifile, the content of the pip file is as follows:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

Insert picture description here
Insert picture description here

Published 113 original articles · Liked 105 · Visitors 20,000+

Guess you like

Origin blog.csdn.net/weixin_43124279/article/details/105410415