Home  >  Article  >  Backend Development  >  How to modify pip source

How to modify pip source

zbt
zbtOriginal
2023-12-05 14:05:081374browse

Steps to modify the pip source: 1. Open the command prompt or PowerShell and enter the pip config list command; 2. Enter the notepad %APPDATA%\pip\pip.ini command in the command prompt or PowerShell; 3. In the open text file, enter index-url = https://mirrors.aliyun.com/pypi/simple/; 4. Save and close the file.

How to modify pip source

The operating system for this tutorial: Windows 10 system, Python version 3.11.4, DELL G3 computer.

To modify the pip source, you can specify a domestic mirror source, which can help speed up the download speed of Python packages, especially in mainland China. In the next 1500-word answer, I will explain in detail how to modify the pip source.

By default, pip downloads Python packages from https://pypi.org, but due to network reasons, sometimes this source may not be stable enough. Therefore, many users hope to switch the default source of pip to a domestic mirror source, such as Alibaba Cloud, Tsinghua University, etc., to improve the download speed of Python packages. Below I'll explain how to do this on Windows, Mac, and Linux systems.

First, I will introduce how to modify the pip source on Windows system:

1. Open the command prompt or PowerShell and enter the following command to view the current pip source:

pip config list

2. Enter the following command in the command prompt or PowerShell to create or edit the pip configuration file (skip to step 4 if you already have a pip.conf file):

notepad %APPDATA%\pip\pip.ini

3. In the opened text file, enter the following content to specify the mirror source, for example, use the Alibaba Cloud mirror source:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

You can also use other mirror sources, such as Tsinghua University's mirror source:

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

4. Save and close the file.

Next, I will introduce how to modify the pip source on the Mac system:

1. Open the terminal and enter the following command to view the current pip source:

pip config list

2. Enter the following command in the terminal to create or edit the pip configuration file (skip to step 4 if you already have a pip.conf file):

nano ~/.pip/pip.conf

3. In the opened text In the file, enter the following content to specify the mirror source, for example, use the Alibaba Cloud mirror source:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

You can also use other mirror sources, such as Tsinghua University's mirror source:

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

4. Press Press Ctrl X, then Y, and finally press Enter to save the file.

Finally, I will introduce how to modify the pip source on the Linux system:

1. Open the terminal and enter the following command to view the current pip source:

pip config list

2. Enter the following command in the terminal to create or edit the pip configuration file (skip to step 4 if you already have a pip.conf file):

nano ~/.config/pip/pip.conf

3. In the open text file , enter the following content to specify the mirror source, for example, use the Alibaba Cloud mirror source:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

You can also use other mirror sources, such as Tsinghua University's mirror source:

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

4. Press Ctrl X, then Y, and finally Enter to save the file.

Through the above steps, you can successfully modify the pip source to a domestic mirror source, thereby increasing the download speed of Python packages.

It should be noted that there may be some problems when using domestic mirror sources. For example, some packages may not exist in domestic mirror sources. Therefore, after switching sources, it is recommended that you be more careful when installing packages to ensure that the required packages can be found in the mirror source.

The above is the detailed content of How to modify pip source. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to Chineseize pycharmNext article:How to Chineseize pycharm