Partners who have just come into contact with Python will certainly use the PIP command to install various third-party libraries, but the readtimeouterror problem often occurs during the installation process.
The reason is that when we use the default PIP source to install the python library, because the downloaded server is abroad, the network speed is particularly slow, and an error will be reported if we don't pay attention. There will be a timeout problem and we can't download it, as shown in the following figure:
So how should we solve this problem?
Method 1: modify the default timeout to make PIP patient and increase the waiting time. In fact, it is to modify the PIP configuration file. The instructions are as follows:
PIP3 -- default timeout = 100 install package name
Method 2: use domestic sources for a single time. Since the network speed of foreign servers is not good, is there a server that can be downloaded in China? Of course!
Tsinghua University has a mirror address: https://pypi.tuna.tsinghua.edu.cn/simple , just add“-I website”You can switch to the specified download address.
For example, if you need to download and install the turtle library, you can write the following instructions:
pip install –i https://pypi.tuna.tsinghua.edu.cn/simple turtle
Method 3: remember the domestic source website every time you install. It's too troublesome! There's a way once and for all? Of course! Create a new PIP folder and configure the pip.ini file. The steps are as follows:
- Create a new PIP folder in the directory C: \ users \ XXX (XXX actually represents the commonly used login users)
- Create a new pip.ini file in the PIP folder, and add the following contents:
[global] timeout = 60000 index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install] use-mirrors = true mirrors = https://pypi.tuna.tsinghua.edu.cn
In this way, the PIP installation source is changed to the domestic source. Once and for all, the download will access the domestic source, which is very fast. Bloggers use the image source of Tsinghua University. Of course, there are other commonly used image sources in China.
Common image sources in China are as follows: Alibaba cloud http://mirrors.aliyun.com/pypi/simple/ China University of science and technology https://pypi.mirrors.ustc.edu.cn/simple/ Douban http://pypi.douban.com/simple/ Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/ University of science and technology of China http://pypi.mirrors.ustc.edu.cn/simple/
When you encounter the PIP download timeout problem, you can basically solve it according to the blogger's above three methods~~~
Creation is not easy, white whoring is not good. Your support and recognition is the biggest driving force for my creation. See you in the next article!
If there are any mistakes in this blog, please comment and advice. Thank you very much!