Skip to content

Instantly share code, notes, and snippets.

@anic1618
Last active November 10, 2022 10:12
Show Gist options
  • Save anic1618/93ecbaf57c746a6b9816f8e51147e833 to your computer and use it in GitHub Desktop.
Save anic1618/93ecbaf57c746a6b9816f8e51147e833 to your computer and use it in GitHub Desktop.
Python package offline install

Offline installation of python packages

see: https://peps.python.org/pep-0425/

1. Download pkgs.

pip download --platform -r requirements.txt -d /path/to/download/dir/

you can replicate remote environment locally i.e. create new virtual environment with same platform, python version and packages as remote. And run above command without platform switch.

try to download wheel

try to install build distribution (wheel). you may use --only-binary=:all: tag for downloading wheel distribution.

e.g. If matplotlib packages have to be install on remote which is linux system and having python version 3.6, following command can be used
pip download --python-version 36 --abi cp36m --platform manylinux1_x86_64 --only-binary=:all: matplotlib

2. Installation

To confirm you have downloaded all packages correctly , install packages locally to confirm. Also you can run your program in this environment

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

if installation failed due to missing package, download missing package into same-directory as given in step 1. Once confirmed downloaded packages are installed correctly, copy all your downloaded packages to remote location and run the command again on remote system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment