/commands/pip/pip-download-offline-install
pip download: get wheels for an offline install (pip install --no-index --find-links)
- tool
- pip
- versions
- pip 20+
- os
- any
pip download -d wheels -r requirements.txt resolves the requirements, including every dependency, and saves the wheel (or source) files into the wheels folder without installing anything. Copy that folder to a machine without internet access and install from it with pip install --no-index --find-links wheels -r requirements.txt, which never contacts an index.
Download a package and its dependencies
echo "requests==2.32.3" > requirements.txt
pip download --disable-pip-version-check -q -d wheels -r requirements.txt
ls wheels | sed -E 's/-[0-9][^-]*-(py|cp).*$//' | sortOutput
certifi charset_normalizer idna requests urllib3
requests brought its four dependencies along, so wheels contains everything an offline install of requirements.txt needs on the same kind of machine. The listing strips the version and platform part of each file name; the folder holds normal .whl files.
Download for another platform
pip download --disable-pip-version-check -q -d linux-wheels \
--only-binary=:all: --platform manylinux2014_x86_64 --python-version 3.12 \
"pyyaml==6.0.2"
ls linux-wheelsOutput
PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
pip chose the CPython 3.12 Linux x86-64 wheel even though the command ran elsewhere. Cross-platform downloads require --only-binary=:all: (or --no-deps), because pip cannot build source distributions for a foreign platform.
Install on the offline machine
pip install --no-index --find-links wheels -r requirements.txt--no-index forbids PyPI and any configured index, and --find-links points pip at the folder (a URL also works). If something is missing, the install fails with No matching distribution found instead of quietly reaching the internet.
Options
| Option | What it does |
|---|---|
| -d, --dest DIR | Folder to save files into (default: the current folder) |
| -r requirements.txt | Download everything a requirements file needs |
| --no-deps | Only the named packages, not their dependencies |
| --only-binary=:all: | Wheels only, never source distributions |
| --no-binary=:all: | Source distributions only |
| --platform TAG | Target platform, for example manylinux2014_x86_64, win_amd64, macosx_11_0_arm64 |
| --python-version 3.12 | Target Python version |
| --implementation cp --abi cp312 | Target interpreter and ABI tags when they matter |
Pitfalls
- Platform mismatch. Wheels with compiled code (numpy, pyyaml, cryptography) are specific to OS, CPU and Python version. Download for the target, not for the machine you are on.
- Index settings still apply to
pip download: a customindex-urlin pip's configuration is used, see pip.conf index-url. - Hash checking. For a fully repeatable offline install, freeze with hashes (
pip-compile --generate-hashesoruv pip compile --generate-hashes) and install with--require-hashes. - Build tools. A source distribution in the folder still has to be built on the offline machine, which needs its build backend (for example setuptools and wheel) in the folder too.
How to confirm it worked
ls wheels should show one file per package of the resolved set. On the offline machine, pip install --no-index --find-links wheels -r requirements.txt finishing without errors, followed by pip check, confirms that nothing was missing.
FAQ
Can I download wheels for Linux from a Windows machine?
Yes, with --only-binary=:all: plus --platform, --python-version and, if needed, --implementation and --abi. pip then selects wheels for that target instead of the current machine. It cannot build source-only packages for another platform.
Why does the offline install say No matching distribution found?
A file it needs is missing from the folder, usually a dependency downloaded for a different platform or Python version than the target machine. Download again with the target's --platform and --python-version, or on a machine like the target.
Does pip download install anything?
No. It resolves the requirements and saves the files to the destination folder. The current environment is not changed.