Completely solve the problem of slow downloading of Python packages

Because Python uses foreign mirrors by default, sometimes the download is very slow. The fastest way is to add domestic sources in the download command:

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

"The commonly used domestic sources are as follows:
Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/
Alibaba Cloud http://mirrors.aliyun.com/pypi/simple/
University of Science and Technology of China https://pypi.mirrors.ustc.edu.cn/simple/
Douban http://pypi.douban.com/simple/
University of Science and Technology of China http://pypi.mirrors.ustc.edu.cn/simple/

However, it is particularly inconvenient to enter the URL every time. In fact, we can modify the download source of pip globally, so that there is no need to write the path of the domestic source in the future.

Windows (example win10)

Create a file pip.ini

document content

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

In the user directory, create a new pip folder

**Check whether the configuration is successful: **

pip config list

See if the download speed has become faster

If it is troublesome, directly execute the following python code to quickly get the configuration.

import os
ini ="[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple/\n"
pippath=os.environ["USERPROFILE"]+"\\pip\\"exec("if not os.path.exists(pippath):\n\tos.mkdir(pippath)")open(pippath+"/pip.ini","w+").write(ini)

Linux or Mac

First create a new .pip folder in the user directory

mkdir ~/.pip

Create a new configuration file pip.conf in this directory, enter the following content, and save:

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

Modify library download source in Pycharm

Open the package download according to the following path in the setting

Click Manage Respositories

Click + to add a domestic source path.

Recommended Posts

Completely solve the problem of slow downloading of Python packages
Solve the problem of python running startup error
Solve the problem of python compiling and installing ssl
Solve the problem of convex hull based on python
Solve the conflict of multiple versions of python
Solve the conflict of multiple versions of python
Solve the problem of installing VMwareTools on Ubuntu 18.04
Solve the problem of installing Theano on Ubuntu19
How to understand the introduction of packages in Python
Detailed explanation of the remaining problem based on python (%)
Consolidate the foundation of Python (4)
Consolidate the foundation of Python(7)
Consolidate the foundation of Python(6)
Consolidate the foundation of Python(5)
Consolidate the foundation of Python (3)
[Share] Solve the problem of failed installation of Vitis 2019.2 on Ubuntu 16.04
The usage of wheel in python
Python handles the 4 wheels of Chinese
Python simulation of the landlord deal
What is the use of Python
The premise of Python string pooling
The operation of python access hdfs
The usage of tuples in python
End the method of running python
Can Python implement the structure of the stack?
Learn the basics of python interactive mode
What are the required parameters of python
Logistic regression at the bottom of python
The usage of Ajax in Python3 crawler
Python solves the Tower of Hanoi game
What is the scope of python variables
Python implements the sum of fractional sequences
Two days of learning the basics of Python
What is the id function of python
Centos 8.1.1911 solves the problem of yum reinstallation
The essence of Python language: Itertools library
The specific method of python instantiation object
python3 realizes the function of mask drawing
What is the prospect of python development
What is the function body of python
The specific method of python import library
What is the function of adb in python
Detailed explanation of the principle of Python super() method
The difference between the syntax of java and python
Solve the problem that Centos8 cannot install docker
Python realizes the development of student management system
Use the command to solve the Ubuntu projector problem:
Python implements the shuffling of the cards in Doudizhu
The meaning and usage of lists in python
Can the value of the python dictionary be modified?
Python implements the source code of the snake game
Detailed explanation of the usage of Python decimal module
How about learning python at the age of 27?
The consequences of uninstalling python in ubuntu, very
Python writes the game implementation of fishing master