In Python, you can modifypip
The configuration file of or use directly on the command line--index-url
Parameters to change the mirror source. Here are a few common methods:
1. Temporarily use the mirror source
You can use it when installing the package--index-url
Parameters temporarily specify the mirror source. For example, use Tsinghua University’s mirror source:
pip install Package name --index-url /simple
2. Permanently modify the mirror source
You can modifypip
configuration file to permanently change the mirror source.
Method 1: Use the command line to set it
You can set the default image source using the following command:
pip config set -url /simple
Method 2: Manually modify the configuration file
You can edit it manuallypip
configuration file. The path to the configuration file is usually located at:
-
Linux/macOS:
~/.pip/
-
Windows:
%APPDATA%\pip\
Add the following to the configuration file:
[global] index-url = /simple
3. List of commonly used mirror source
Here are some commonly used PyPI image sources:
-
Tsinghua University:
/simple
-
Alibaba Cloud:
/pypi/simple
-
Douban:
/simple
-
University of Science and Technology of China:
/simple
4. Restore the default source
If you want to restore the default PyPI source, you can delete theindex-url
Configure, or use the following command:
pip config unset -url
so,pip
The default will be reused/simple
Source.
5. Use the file
If you areThe dependency package is specified in the file and can be used during installation.
--index-url
Parameters:
pip install -r --index-url /simple
Through the above methods, you can easily modify Python's mirror source to speed up the download of packages.
This is the article about the methods and steps of modifying the mirror source in python. For more related contents of modifying the mirror source in python, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!