How to Install Python Packages Without Internet Access
This note describes how to install python packages without Internet connectivity.
Download Packages in an Online Environment
First, use the pip download command in an environment with Internet access to download the required Python packages.
pip install boto3pip freeze > requirements.txtpip download --dest packages -r requirements.txtThis will save the packages and their dependencies to a directory named packages.
Transfer the Packages to the Offline Environment
Compress the downloaded packages into an archive file and transfer it to the target environment without Internet connectivity using a secure method like scp.
tar cvzf packages.gz ./packages# Transfer the archive to the offline environmentInstall Packages in the Offline Environment
Once transferred, extract the archive and use pip install with the --find-links and --no-index options to install the packages.
tar xvzf packages.gzpip install -r requirements.txt --find-links packages --no-indexThe --find-links option points to the local directory containing the packages, and --no-index ensures pip does not try to access the PyPI index.