Home > Backend Development > Python Tutorial > How to set up pip source

How to set up pip source

zbt
Release: 2023-12-05 14:22:33
Original
2586 people have browsed it

Set the pip source by finding the pip source configuration file, editing the pip source configuration file, saving and closing the file, updating the pip source cache, and using the new pip source. Detailed introduction: 1. Find the pip source configuration file. Under Windows system, the pip source configuration file is in C:\Users\your username\AppData\Local\pip\pip.ini, C:\Program Files\pip\pip. ini and so on.

How to set up pip source

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

Setting the pip source is mainly to change the default source of pip and solve the problem that the installation package cannot be downloaded normally when using pip in China. The following are the specific setting steps:

1. Find the pip source configuration file

Under Windows systems, the pip source configuration file is usually located in one of the following two locations:

C:\Users\yourusername\AppData\Local\pip\pip.ini

C:\Program Files\pip\pip.ini

On Unix /Under Linux systems, the pip source configuration file is usually located at the following location: /usr/local/lib/python2.7/site-packages/pip/pip.conf

2. Edit the pip source configuration file

Open with a text editor Find the pip source configuration file, find the [global] section in the file, and add the following content under this section:

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

This is the Python image source provided by Tsinghua University, which can significantly improve the efficiency of domestic users when using pip download speed. You can also change to other mirror sources you like. For example, if you want to use Alibaba Cloud's Python mirror source, you can modify the above configuration to:

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

3. Save and close the file

Save the pip Make the modifications to the source configuration file and then close the text editor.

4. Update the pip source cache

Open the command line terminal and enter the following command to update the pip source cache:

python -m pip cache purge
Copy after login

5. Use New pip source

Enter the following command in the command line terminal to verify whether the new pip source takes effect:

python -m pip install --upgrade requests
Copy after login

If you see something like "from: https://pypi.tuna.tsinghua.edu.cn/simple" output information, it means that the new pip source has taken effect. If there is no similar output information, please check whether your network connection is normal and the pip source configuration Whether the file is configured correctly.

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

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template