Python uses PIP free and dowload to print offline packages and install them automatically [suitable for confidential offline environment]


Pip of Python is its package management tool, which is quite convenient and easy to use. This article only introduces how PIP can use its softwarefreezeCommand to print the offline package and its installation script. This knowledge point is especially applicable to devices that are not suitable for connecting to the Internet and need to be physically isolated,Strict confidentiality requirementsCustomer environment.


Environmental Science

Operating system: Centos 7.7

Python version: 2.7

Customer network environment: offline

R & D network environment: Networking


  • PIP installation

(1)Download RPM package

First, research and development environment (Networking), to the appropriate PIP RPM offline package to download, as shown in the figure below:

Select an RPM link, click in, and then in the download module, select the binary file related download address to download【CoderBaby】, as shown in the figure below:


 (2) RPM install PIP offline package

rpm -ivh python2-pip-8.1.2-10.el7. noarch.rpm (RPM) offline packageFull pathname


(3) Upgrade pip

Upgrade pip to the latest version through the old version of PIP install command, as follows:

pip install packages/pip-20.2.3-py2.py3-none- any.whl (download from pypi website).whlPackage:


(4) PIP freeze packages the installed packages in the required format

The specific orders are as follows:

pip freeze > requirements.txt (redirect, and specify the output file name, format, and path)

The results are as follows


(5) PIP download download offline package

The specific orders are as follows:

pip download -d packages -r requirements.txt (will) requirements.txt The package name and version specified in the requirements.txt , delete packages that do not need to be packaged] and package them in the default packages folder.)

The results are as follows:


(6) Install offline package through shell script

The specific shell script commands are as follows:

pip install –no-index –find-links=packages -r requirements.txt 


First, the packages folder and requirements.txt Copy to offline server: put the packages folder in any directory, requirements.txt Put it in the same level directory

The related directory structure is as follows:



  • Upgrade Python 2.6.6 to 2.7

centos 6 The built-in Python version is 2.6.6, which needs to be upgraded to 2.7. For details, please refer to: 

【@2020/12/7CentOS 6 has been abandoned by major domestic imagesBecause as of November 30, 2020, centos6 has stopped maintenance and update. See: