Changing the pip Source
To change the pip source to the Tsinghua mirror, you can follow these steps:
Temporarily Using the Tsinghua Mirror
If you only want to use the Tsinghua mirror for a single installation, you can specify it in the command:
pip install <package_name> -i https://pypi.tuna.tsinghua.edu.cn/simple
For example:
pip install powerinfer -i https://pypi.tuna.tsinghua.edu.cn/simple
Permanently Changing the pip Source
If you want to permanently change the pip source, you can do so by modifying the pip configuration file.
1. Linux or macOS
Create or edit the .pip/pip.conf file in your home directory:
mkdir ~/.pip
nano ~/.pip/pip.conf
Then add the following content:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
Save and exit (in nano, press Ctrl+O to save, press Ctrl+X to exit).
2. Windows
Create or edit the pip configuration file in the user directory. The specific path is: %HOMEPATH%\pip\pip.ini. You can follow these steps:
-
Open the command prompt (cmd).
-
Create the directory (if it doesn't exist):
mkdir %HOMEPATH%\pip -
Edit the
pip.inifile using Notepad:notepad %HOMEPATH%\pip\pip.ini -
Add the following content in Notepad:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple -
Save and close Notepad.
Verify Configuration
You can run the following command to verify whether the pip source has been successfully changed:
pip config list
If configured correctly, you should see index-url set to the Tsinghua mirror.
You have now successfully changed the pip source to the Tsinghua mirror.