pip batch installation of Python library requirement.txt pip installation of Python library in offline environment without Internet environment

Cause background

I usually need to write some scripts in Python to process data, but the working environment is quite special.
The development environment is an Internet environment, and the deployment environment is an isolated environment without the Internet,
so record the processing plan.

Installation process

1. Install all

Export all libraries in the current computer environment

First, export all local libraries to a text file
(local may be pip or pip3 )

pip freeze > requirements.txt

Then create a new directory under the directory to save our files (the folder name here is DIR)
and download the library list in requirements.txt to a local folder
(the local folder may be pip or pip3 )

pip wheel -w DIR -r requirements.txt
pip download -d DIR -r requirements.txt

Insert image description here

Finally, copy the current directory to the USB disk and copy it to the target computer.
Execute it in the directory of the target computer
(locally it may be pip or pip3 )

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

2. Partial installation

Export only part of the library according to certain rules

If it is only partial, then we manually create a new text file called: requirements.txt.
Open the text file and write the required libraries
, such as: openpyxl, pandas, numpy,
and then execute the process above. The only difference is that the content of requirements.txt is different.

Guess you like

Origin blog.csdn.net/w776341482/article/details/128711712