SoFunction
Updated on 2025-04-11

Steps to modify the image source in python

In Python, you can modifypipThe configuration file of  or use directly on the command line--index-urlParameters 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-urlParameters 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 modifypipconfiguration 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 manuallypipconfiguration 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-urlConfigure, or use the following command:

pip config unset -url

so,pipThe default will be reused/simpleSource.

5. Use the file

If you areThe dependency package is specified in the file and can be used during installation.--index-urlParameters:

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!