Installing Python Packages Without Internet Access
This note describes how to install python packages without Internet connectivity.
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.
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.
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.
Related posts
Monitoring OPC UA Variable Nodes with Python
Subscribing to OPC UA variable node changes with opcua-asyncio so the client reacts to pushed updates instead of polling.
Performing OCR on Japanese PDFs Using Tesseract and Pytesseract
Extracting Japanese text from a PDF with Tesseract OCR v4 and pytesseract, including the normalization step needed to clean up the output.
Running Proxy.py as a Lightweight HTTP Proxy on EC2
Running Proxy.py on an EC2 instance and reaching it safely through an SSH tunnel, since the proxy has no authentication of its own.

Dependency Injection for Maintainable, Testable Code
Refactoring a tightly coupled TypeScript class into one that's testable with mocks, using Dependency Injection for the salary calculator, the system clock, and SES.
Spying on Mock Object Properties in Jasmine
Working around Jasmine's "already been spied upon" error when spying on a mocked object's property with Object.getOwnPropertyDescriptor.
