Two methods to solve the problem of slow pip download speed and pip switch source download

pip, conda switch source installation, significantly improve the speed! ! !

The first method (for pip)

temporary method

When using pip install xxx, use the following command:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xxx

Among them, xxx is the name of the package you want to install.

permanent method

Under Windows, first open the command terminal and enter set to find the path of this folder. Insert image description here
Then directly create a pip directory in this directory, such as: C:\Users\Administartor\pip, and create a new file pip.ini with the following content
Insert image description here

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

Under Linux,
create a .pip file in the user's root directory. For example, if my user name is hh, then create it under hh/. Note that there is a dot in front of it, then enter the folder, create the pip.conf file, open it and enter the following Content, the source inside can be changed at will. Alibaba Cloud and Douban are used here.

[global]
timeout = 10 
index-url =  http://mirrors.aliyun.com/pypi/simple/ 
extra-index-url= http://pypi.douban.com/simple/ 
[install]
trusted-host= 
    mirrors.aliyun.com
    pypi.douban.com

Second method (for conda)

Enter the following three commands, one by one! ! !

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

After the input is completed, you can happily perform conda install xxx. I hope it is useful to everyone.

Guess you like

Origin blog.csdn.net/laojie4124/article/details/103707534