Please, don't use the speed of pip to install libraries anymore!

To learn Python, it is far from enough to only master the standard library. There are many useful third-party libraries that we also need to use. For example, the requests library, which is indispensable for crawlers developed by the famous K God, is generally required. Install the library. It is of course the most convenient to install third-party libraries with the pip command.

However, everyone found that when installing a third-party library with pip install + package name, the download speed is very slow, and sometimes it will time out. When the third-party library is relatively large, it is really slow. When I first started learning Python , I was careless, I didn't expect it to be so slow. By the way, I sometimes mentioned pants, but it reported that the installation timed out. . . Keke, get back to business, today I will teach you how to solve this damn turtle speed problem.

There are two main ways to speed up pip, one is temporary speed increase and the other is permanent speed increase.

Temporary speed increase

Add -i + mirror address to the pip install package name, so that pip installation can be doubled in speed.

The main domestic mirror addresses are as follows:

Tsinghua: https://pypi.tuna.tsinghua.edu.cn/simple

Aliyun: http://mirrors.aliyun.com/pypi/simple/ University of Science and Technology of China

https://pypi.mirrors.ustc.edu.cn/simple/

Huazhong University of Science and Technology:
http://pypi.hustunique.com/ Shandong University of Technology: http://pypi.sdutlinux.org/
Douban: http://pypi.douban.com/simple/

Many people learn python and don't know where to start.
Many people learn python and after mastering the basic grammar, they don't know where to find cases to get started.
Many people who have done case studies do not know how to learn more advanced knowledge.
For these three types of people, I will provide you with a good learning platform, free to receive video tutorials, e-books, and course source code!
QQ group: 810735403

So the format for temporarily speeding up pip installation is as follows:

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

Permanently speed up

It is troublesome to temporarily copy the mirror address every time, so the method to permanently speed up is introduced next. Do a simple configuration to complete.

Windows system configuration
1. Create a file pip.ini in C:\Users\Administrator\pip. If there is no pip folder in Administrator, create a new one by yourself, and then create a new pip.ini file

2. Enter in the pip.ini file:

[global]
index-url = https://pypi.douban.com/simple

[install]
trusted-host = pypi.douban.com

Use Notepad's default ANSI encoding format to copy and paste the text above.

Mac and Linux configuration

1. Open terminal

2. Enter the command:

mkdir .pip
vim .pip/pip.conf

(The two steps are to create a new file in the home directory: .pip/pip.conf)

Press the i key to enter the input mode, copy and paste the following content in this file:

[global
index-url = https://pypi.doubanio.com/simple/
timeout = 1000
【install】
use-mirrors = true
mirrors = https://pypi.doubanio.com//

After pressing ESC to exit the insert mode, directly type: wq and press Enter, so that the file and input content just created will be saved and exited.

The speed-up effect is as shown in the figure below (the speed in the figure is the real download speed and has not been processed).
Insert picture description here
Here I still recommend the Python development exchange learning (qq) group I built:, the 810735403group is developed by learning Python, if you I am learning Python, and you are welcome to join. I have compiled a copy of the latest Python advanced materials and advanced development tutorials for 2021. Welcome to the advanced and those who want to go deep into Python!

Guess you like

Origin blog.csdn.net/XIe_0928/article/details/112360022