brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: pip download collects wheels so you can install without internet

Pip
~/tips/tip-pip-download-offline-install

python3 -m pip download -r requirements.txt -d ./wheels

Fetch packages and dependencies on one machine and install them on another.

A server with no route to the package index still needs its packages. Collect them somewhere with a connection, carry the folder over, and install from it.

On the machine that is online:

python3 -m pip download -r requirements.txt -d ./wheels

This saves each package and its dependencies as files and installs nothing. Copy wheels and the requirements file to the other machine, then run:

python3 -m pip install --no-index --find-links=./wheels -r requirements.txt

--no-index tells pip to stay away from PyPI, and --find-links points it at your folder. If something is missing you get an error right away, which I prefer to a silent attempt to reach the network.

The part that trips people up is platforms. By default pip downloads files that fit the machine you run it on. A wheel fetched on a Mac won’t install on a Linux server, and a different Python version can be a problem too. The easiest fix is to download on a machine that matches the target. pip also has --platform and --python-version for this, together with --only-binary=:all:.

Further reading: pip download

More Pip tips urllib3<2 python3 -m pip config set global.timeout 60 python3 -m pip index versions requests python3 -m pip download requests==X.Y.Z --no-deps -d ./pkgs python3 -m pip install --only-binary=:all: numpy All Pip tips (9) All topics

Link