Python replacement pip source method process analysis

When using Python, you need to use a variety of libraries, usually using pip to install directly, which is the simplest and most convenient. But the biggest crash is that sometimes the speed is surprisingly slow, because the source used by pip by default is the official source, and the official source is abroad. The usual solution is to replace the source. Common domestic sources are as follows:

https://pypi.tuna.tsinghua.edu.cn/simple/ Tsinghua
http://pypi.doubanio.com/simple/ Douban
http://mirrors.aliyun.com/pypi/simple/ Ali
https://pypi.mirrors.ustc.edu.cn/simple/ University of Science and Technology of China
http://mirrors.163.com/pypi/simple/ NetEase

Permanently replace the source under Windows

  1. Enter %APPDATA% in the run window or explorer

  1. After entering the directory, create a new folder pip, and create a new file pip.ini in the folder, and enter the following:

The text content is as follows:

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

  1. Next time you use pip to install, you can replace it with a domestic pip source.

Permanently replace the source under Linux

  1. Create a .pip directory in the home directory

mkdir -p ~/.pip

  1. Create pip.conf file

vim ~/.pip/pip.conf

  1. Enter the following and save

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

Temporarily change the pip source

pip install <package name-i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn

The above is the whole content of this article, I hope it will be helpful to everyone's study.

Recommended Posts

Python replacement pip source method process analysis
Python file operation basic process analysis
Python process and thread summary case analysis
Method analysis of Python calling C language program
Python data analysis
Python magic method topic
Python object-oriented magic method
Centos source installation Python3
Python linear interpolation analysis
Python function-dictionary get() method
Python error handling method
Python process pool: multiprocessing.pool