Python third-party libraries download installation packages in batches and install Python third-party libraries offline in batches

Time:2021-9-15

It is very isolated from the internal and external networks of the enterprise. It is impossible to directly install the third-party package through the PIP install package command. We can download the third-party package on the external network and then copy it to the office computer for installation.
However, in some cases, we need to download n third-party packages, or the downloaded packages rely on other packages, which is a waste of time. At this time, we can batch download through the following two commands.
Method 1: single download

#Single package download method 1:
PIP download your package name - D "download path folder" # for example: Download pymysql package to D: \ packages
PIP download pymysql - D "D: \ packages" # single package download method 2:
PIP download - D storage path package name # for example: Download pymysql to D: / packages
pip download -d D:/packages pymysql

Method 2 batch download installation package:

pip download -d D:/packages -r requirements.txt

How to generate requirements.txt? Reference link:   https://www.jianshu.com/p/a46160ab35b4

Requirements.txt is the list of packages we need to download, for example

certifi==2020.11.8
chardet==3.0.4
filelock==3.0.12
idna==2.10
requests==2.25.0
requests-file==1.5.1
selenium==3.141.0
selenium-requests==1.3
six==1.15.0
tldextract==3.1.0
urllib3==1.26.2

 

After the third-party package is downloaded, we install it through the following command
Mode 1   Single package installation:

pip install --no-index --ignore-installed --find-links=D:/packages

Mode 2   Batch install local installation package:

pip install --no-index --ignore-installed --find-links=D:/packages -r requirements.txt

 

If there is any mistake, please correct it. Thank you   / Boxing