Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of Read timed out when installing the library in pip in python

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to solve the problem of Read timed out when installing the pip library in python". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the problem of Read timed out when there is a pip installation library in python".

First, I updated the pip, as shown in the following figure:

Attached is the screenshot of success:

Then install the numpy library:

Installing libraries in this regular way can lead to time out, that is, timeouts. Here is my solution:

Solution 1: extend timeout time

Raise ReadTimeoutError (self._pool, None, 'Read timed out.')

ReadTimeoutError: HTTPSConnectionPool (host='files.pythonhosted.org', port=443): Read timed out.

Pip-default-timeout=100 install Package

Just replace Package with the library you need.

Solution 2: change the source and change the pip source to the domestic image. This method is recommended by individuals # for example, the source pip install of Douban is used when installing scipy-- index-url https://pypi.douban.com/simple scipy# uses the source pip install-I https://pypi.tuna.tsinghua.edu.cn/simple-upgrade tensorflow-gpu of Tsinghua University

Change the pip source to the domestic image

When installing library files with pip management tools, foreign source files are used by default, so the download speed in China will be relatively slow, perhaps only 50KB/s. Fortunately, some of the top scientific research institutions in China have prepared various images for us, and the download speed can reach 2MB/s.

Among them, the more commonly used domestic images include:

(1) Aliyun http://mirrors.aliyun.com/pypi/simple/

(2) Douban http://pypi.douban.com/simple/

(3) https://pypi.tuna.tsinghua.edu.cn/simple/ of Tsinghua University

(4) http://pypi.mirrors.ustc.edu.cn/simple/ of University of Science and Technology of China

Take Tsinghua Source as an example, the setting method is as follows:

You can add the parameter-I and the image address (such as https://pypi.tuna.tsinghua.edu.cn/simple)) when using pip

For example: pip install-I https://pypi.tuna.tsinghua.edu.cn/simple pandas, so that the Pandas library is installed from the Tsinghua image.

The successful screenshot is as follows:

In the same way, I downloaded the matplotlib library:

When you go back to python after installation, you can import the corresponding package.

Finally succeeded in drawing a circle.

Thank you for your reading, the above is the content of "how to solve the Read timed out when installing the pip library in python". After the study of this article, I believe you have a deeper understanding of how to solve this problem when you install the pip library in python, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report