Backend Development 10 min read

How to Install PyPI Packages Offline with pip: A Complete Guide

This guide explains how to work around restricted network environments by downloading Python packages and their dependencies from PyPI, storing them locally, and using pip with --no-index and --find-links options to install them without internet access.

Code Mala Tang
Code Mala Tang
Code Mala Tang
How to Install PyPI Packages Offline with pip: A Complete Guide

Due to security restrictions, some internal networks cannot access the internet directly; servers are completely offline and workstations have limited internet access, requiring files to be security‑scanned before download. In such cases the default Python package manager pip cannot fetch packages from PyPI.

Solution Overview

We download the required Python packages and their dependencies from PyPI, place them in a local folder, and then instruct pip to look for packages in that folder instead of PyPI.

pip Does Behind the Scenes

For background on pip , see https://realpython.com/what-is-pip/.

When we run pip install <package-name> , pip searches PyPI, downloads the package, and uses a file such as requires.txt (or requirements.txt ) to determine dependencies, recursively downloading all needed dependencies.

If you closely examine the log after running pip install <package-name> , you can see this process.

After all dependencies are downloaded, pip installs them into the Python environment and performs additional maintenance; the installed packages can then be used by Python applications running in that environment.

The term “Python environment” refers to a Python virtual environment.

How to Install PyPI Packages Without Internet?

We instruct pip not to search PyPI but to look for packages in a specified local folder.

<code>pip install --no-index --find-links=&lt;local_folder&gt; &lt;package-name&gt;
# Example:
pip install --no-index --find-links=/tmp/python-wheels exchangelib</code>

Running pip install with the --no-index option prevents PyPI searches, and --find-links tells pip to locate and install the package and its dependencies from the given folder.

For pip to succeed, the folder specified by --find-links must contain the package, its dependencies, and the dependencies of those dependencies.

How to Put PyPI Packages and Their Dependencies into a Local Folder?

Example: to install the exchangelib package, run:

<code>pip install --no-index --find-links=&lt;local_folder&gt; exchangelib</code>

First, on a machine with internet access, visit https://pypi.org/, search for exchangelib , and open its page.

PyPI page
PyPI page

Click the “Download files” link to reach the download page.

Download page
Download page

The page shows two files: a Python wheel file and a tarball (source). pip can install from either; if both are present, the wheel is preferred.

For some packages (e.g., numpy ) you may see multiple files; typically both a wheel and a source tarball are available.

Download the wheel file and place it in the local folder; if no wheel is available, download the source tarball.

To view dependencies, you need the source tarball.

How to Find Dependencies?

Via requires.txt

Open the downloaded source (tarball) with a ZIP tool and look for requires.txt or, if missing, requirements.txt . These files list the package’s dependencies.

Download the wheel files for those dependencies and put them in the local folder. pip can automatically select the appropriate wheel, falling back to the source tarball if needed.

Via Trial and Error

Alternatively, place the wheel or source in the folder and run pip install . If it fails, the error will indicate a missing dependency; download that dependency’s wheel and repeat until all dependencies are satisfied, then pip will install the package successfully.

It is recommended to first use requires.txt to gather dependencies, then apply trial‑and‑error for any missing pieces.

What If Multiple Wheel Files Exist?

Sometimes a package’s download page lists more than one wheel file.

Multiple wheel files
Multiple wheel files

Why Are There Multiple Wheel Files?

Because the package may contain architecture‑specific code or code that varies with the Python version.

Some packages, like numpy , include compiled C/C++ modules; compiled binaries depend on the target architecture (e.g., Linux 32‑bit, Linux 64‑bit, Windows 32‑bit, Windows 64‑bit, macOS, etc.).

Other packages may have different wheels for different Python versions.

How to Choose the Correct Wheel File?

First check your Python version to see which wheels are compatible.

Then examine the file name to identify the target platform: manylinux for Linux, win for Windows, or macosx for macOS.

Finally, determine the target architecture:

Windows: win32 (32‑bit) win_amd64 (64‑bit)

Linux: manylinux1_i686 (32‑bit) manylinux1_x86_64 (64‑bit)

macOS: macosx_10_9_x86_64 (64‑bit)

With this information you can uniquely identify the wheel file that matches your server or workstation.

Conclusion

Using a package manager to install and maintain dependencies in a specific environment is essential and convenient. In restricted environments, the package manager’s ability to search PyPI is limited. To work around this, download the required packages and their dependencies to a local folder and install them with pip using the --no-index and --find-links options.

dependency-managementVirtual Environmentpipoffline installationwheelPython packages
Code Mala Tang
Written by

Code Mala Tang

Read source code together, write articles together, and enjoy spicy hot pot together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.