Install pip packages offline

Sometimes you might need to download some pip packages offline on a device with no Internet access. This is entirely feasible through multiple ways.

Install a single package:

You first need to download that package on a device with Internet access (using pip package as an example)

wget https://files.pythonhosted.org/packages/6a/df/a6ef77a6574781a668791419ffe366c8acd1c3cf4709d210cb53cd5ce1c2/pip-22.0.3-py3-none-any.whl

Then you push that file to the device you need to install the package on, and you can execute:

pip install pip-22.0.3-py3-none-any.whl

Install a list of requirements:

You first need to download the list of packages needed from the requirements.txt file:

pip download -r requirements.txt

Then, push all the downloaded files to the server, and install those requirements on the server, using the downloaded packages:

pip install --no-index --find-links /path/to/download/dir/ -r requirements.txt