Installing Python Packages Without Internet Access

Installing Python Packages Without Internet Access

This note describes how to install python packages without Internet connectivity.

Takahiro Iwasa
2 min read

Installing Python packages on a machine without Internet access means downloading them elsewhere first and transferring the result over. The process breaks down into three steps.

Download Packages in an Online Environment

First, use the pip download command in an environment with Internet access to download the required Python packages.

Terminal window
pip install boto3
pip freeze > requirements.txt
pip download --dest packages -r requirements.txt

This 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.

Terminal window
tar cvzf packages.gz ./packages
# Transfer the archive to the offline environment

Install 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.

Terminal window
tar xvzf packages.gz
pip install -r requirements.txt --find-links packages --no-index

The --find-links option points to the local directory containing the packages, and --no-index ensures pip does not try to access the PyPI index.

Conclusion

Downloading packages with pip download on a connected machine and installing them on an offline one with --find-links and --no-index got pip install -r requirements.txt working without any network access at install time. The combination of those two flags is what makes it work: --find-links tells pip to treat the local packages directory as a source of distributions, and --no-index stops it from trying to reach PyPI at all. That earlier pip download step fetches wheels matching the platform, Python version, and architecture of the machine it runs on, so if the online and offline environments differ, it’s worth passing explicit --platform, --python-version, and --implementation flags (with --only-binary=:all:) at download time to avoid ending up with wheels the offline target can’t use.

About the author

Takahiro Iwasa

Takahiro Iwasa

Software Developer

This blog shares technical notes from hands-on projects—architecture, implementation, and AWS service integrations.