Simple operation, easily configure pip mirror source directory!
Introduction:
In the process of using Python to develop, we often need to use pip to install and manage third-party libraries. However, due to network reasons, downloading using the default official mirror source may be slow or even fail. Therefore, many developers will choose to use domestic mirror sources to speed up downloads. This article will introduce how to configure the pip mirror source and provide some commonly used domestic mirror sources for everyone to choose from.
1. How to configure the pip mirror source:
pip install -m https://mirrors.aliyun.com/pypi/simple 包名
pip
in the user directory (if there is no such folder, you need to create it manually), create a file named pip.ini
under the folder, and then Add the following content to the file: [global] index-url = 镜像源地址
Taking the mirror source of Tsinghua University as an example, the configuration file content is as follows:
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
2. Commonly used domestic mirror sources:
Alibaba Cloud provides a stable and reliable mirror source with fast download speed and is recommended.
Tencent Cloud mirror source is also a good choice, download It's also very fast.
The mirror source of Tsinghua University is a well-known open source mirror site in China , the download speed is also very fast.
The mirror source provided by Huawei Cloud is also an optional mirror. source, the download speed is faster.
3. Sample code:
The following is a sample code for pip installation using Alibaba Cloud mirror source:
pip install -m https://mirrors.aliyun.com/pypi/simple requests
After configuring the mirror source, when using pip to install a third-party library, You can use the pip command directly without adding the -m parameter:
pip install requests
4. Summary:
Configuring the pip mirror source can improve the installation speed of third-party libraries and make the development process more efficient. This article introduces how to configure pip image sources, and provides some commonly used domestic image sources for everyone to choose from. Hope this article is helpful to everyone!
The above is the detailed content of Quick settings, one-click configuration of pip mirror sources!. For more information, please follow other related articles on the PHP Chinese website!