How to Install Python Packages Offline in Minutes

Published on: May 19, 2026
Reading time: 9 minutes
Instalação offline de pacotes Python sem internet

Have you ever needed to install a specific library on an isolated server or a computer with no internet access? Whether it is a corporate security requirement, a data center with a restricted network, or simply a location with unreliable connectivity, knowing how to install Python packages offline is an indispensable skill for any developer. Python’s ecosystem relies heavily on pip and the PyPI (Python Package Index) registry for online installations. However, with the right commands and a bit of planning, you can carry your entire development environment on a USB drive and have everything configured in minutes.

For anyone accustomed to the simplicity of pip install library-name, doing this without internet may sound complex. In practice, the process comes down to downloading the necessary files (called wheels) on a connected machine and then pointing pip to those local files on the destination machine. This guide covers the full technical walkthrough, from downloading dependencies to handling cross-platform issues and building a permanent internal package mirror for teams. It complements the best practices described in the guide on Python virtual environments, since offline installations work best inside isolated, reproducible environments.

Why Learn Offline Package Installation?

Several real-world scenarios make offline installation a critical skill. Large enterprises commonly use internal networks (intranets) completely disconnected from the public internet to prevent external attacks and data leaks. Data science projects often require workstations to remain offline for legal compliance when handling sensitive personal information. And if you plan to run Python scripts in Docker in restricted production environments, you will need to manage dependencies locally without relying on external servers at all.

Reproducibility is another major advantage. By downloading packages manually, you guarantee that you have exactly the versions you tested with, preventing a surprise upstream update from breaking your code. According to PyPI, the index hosts hundreds of thousands of packages, and managing that dependency tree reliably is a professional responsibility that offline workflows handle with complete control.

What You Need: Two Machines

To complete the offline installation successfully, you need two computers. The first is the Source Machine, which has internet access and is where you will download all necessary packages. The second is the Target Machine, which is isolated and where the software will be installed. Both should ideally have the same Python version to avoid binary compatibility errors between library versions.

Make sure Python is correctly configured on the target system before starting. The guide on how to install Python walks through the full setup process including pip configuration. With the interpreter working, the next step is gathering the complete list of everything your project needs to run.

Step 1: Downloading Dependencies on the Connected Machine

The first command every developer must know for this process is pip download. Unlike the standard install command, it only fetches the .whl (Wheel) files or source archives and saves them to a local folder without installing them on the current system. Using a requirements.txt file is the cleanest approach, since it captures every dependency your project needs in one place:

# Create a directory to store the packages
mkdir python_packages
cd python_packages

# Download all packages listed in the requirements file
pip download -r requirements.txt -d "./"

The -d "./" parameter tells pip to save the downloads in the current folder. Pip is smart enough to resolve the entire dependency tree automatically, downloading not only the library you requested but also all of its transitive dependencies. For example, requesting Pandas will automatically pull NumPy and other base libraries.

Step 2: Handling Cross-Platform Differences

A common mistake when downloading packages for offline use occurs when the connected machine runs Windows but the target machine runs Linux or vice versa. Wheel files can be specific to a CPU architecture or operating system, especially those that contain compiled C extensions. To download packages for a different system than the one you are currently on, specify the target platform explicitly:

# Download packages for Linux 64-bit from a Windows machine
pip download 
    --only-binary=:all: 
    --platform manylinux1_x86_64 
    --python-version 3.9 
    --implementation cp 
    --abi cp39 
    -r requirements.txt -d "./linux_packages"

This guarantees that when you arrive at the isolated environment, you will not encounter “incompatible architecture” errors that would block the installation. If you are unsure which build variant to download, the PyPI page for each library lists every available file under the “Download files” tab, clearly labeled with its compatible platforms.

Step 3: Transferring Files to the Isolated Network

With the folder full of .whl files, transfer them to the offline machine. The most common method is a USB drive or external hard disk formatted in a compatible file system (NTFS or exFAT). In highly secure corporate environments, this transfer may pass through a kiosk scanning station that checks for viruses before the media is allowed inside the air-gapped network.

Always copy the original requirements.txt file alongside the wheels. It acts as the installation map. Without it, you would need to install each file manually in the correct dependency order, which is a recipe for errors because transitive dependencies must be installed before the libraries that depend on them. Using the Python os module to verify that all expected files are present before starting the installation is a good defensive practice.

Step 4: Performing the Offline Installation

On the offline machine, open a terminal and navigate to the folder where you copied the files. The key is using two specific pip flags together: --no-index tells pip not to attempt any connection to PyPI, and --find-links tells it which local directory to search instead:

# Install all packages from the local folder
pip install --no-index --find-links="./" -r requirements.txt

Pip will read the requirements file and, instead of making an HTTP request, will look for matching wheel files in the current directory. If all files are present, the installation completes in seconds, often much faster than an online installation because there is no network latency involved. If you encounter a PermissionError in Python during installation, try running the terminal as administrator or adding the --user flag to install packages for your current user only.

Understanding Wheel Files (.whl)

Wheel files are the gold standard for modern Python package distribution. They are pre-compiled, meaning that when you install a wheel offline, you avoid needing a C compiler or Fortran toolchain on the target machine. This is critical because offline machines are often “clean” systems without build tools. If you download a .tar.gz (source distribution) instead, pip will attempt to compile the code at installation time and fail if the build tools are not present. Always prefer wheel files using the --only-binary=:all: flag during the download step to guarantee a smooth offline installation. The guide on how to create an installable pip package explains the internal structure of these files in detail.

Online vs Offline Installation Comparison

FeatureOnline (pip install)Offline (local wheel)
SpeedDepends on connectionExtremely fast (disk read)
SecurityRisk of new malicious packagesFully controlled and auditable
Ease of useHigh (one command)Medium (requires prior preparation)
Dependency resolutionAutomatic via PyPIDepends on downloading all pieces correctly

Offline Installation with Anaconda and Conda

If you manage packages through Anaconda or Miniconda, the process is slightly different. Conda uses .tar.bz2 or .conda package files. You can use conda install --download-only on a connected machine, but managing transitive dependencies manually in Conda is more complex than with pip. An efficient alternative is to create a complete environment on the online machine, export it with conda pack, and transfer the compressed archive. The guide on how to create a Conda environment for Python covers the portability patterns in detail.

Advanced Practice: Building a Permanent Private Mirror

For companies with dozens of developers working in restricted environments, passing USB drives around is not a scalable solution. The professional approach is to set up a private package mirror using tools like devpi or Sonatype Nexus. These systems act as a private PyPI inside the company network.

Developers configure pip to point to the internal server’s IP address. This combines the simplicity of the standard install command with the complete security of an air-gapped network. For managing which packages enter the internal registry in large organizations, using Poetry for dependency resolution before injecting them into the private server is a common enterprise workflow.

Automating the Process

If you deal with restricted environments frequently, a small Python script that automates the download and folder organization steps can save hours of work. With knowledge of automating tasks with Python, you can write a script that reads your configuration file, downloads the correct versions for three different operating systems, and generates a compressed archive ready to be carried to the field. Using pip-compile from the pip-tools package also helps pin versions, ensuring that nothing changes between the download and installation steps.

Complete Reference: Most Useful Commands

# 1. Generate requirements.txt from current environment
pip freeze > requirements.txt

# 2. Download all packages (with dependencies) to a folder
pip download -r requirements.txt -d "./packages"

# 3. Download ONLY wheel binaries (no source distributions)
pip download --only-binary=:all: -r requirements.txt -d "./packages"

# 4. Download for a different platform (e.g., Linux from Windows)
pip download --only-binary=:all: --platform manylinux1_x86_64 
    --python-version 3.9 --implementation cp --abi cp39 
    -r requirements.txt -d "./linux_packages"

# 5. Install from local folder on the offline machine
pip install --no-index --find-links="./packages" -r requirements.txt

# 6. Install a single wheel file directly
pip install ./packages/requests-2.31.0-py3-none-any.whl

# 7. Install without dependencies (use only when sure)
pip install --no-deps ./packages/mypackage.whl

Frequently Asked Questions

What should I do if the downloaded package does not work on the offline server?

Check that the Python version and architecture (32-bit or 64-bit) are identical between the two machines. Run python --version and python -c "import platform; print(platform.architecture())" on both systems to confirm.

Do I need to download pip separately for the offline machine?

Generally pip comes bundled with Python. If it is missing, download the get-pip.py bootstrap script on the online machine and transfer it alongside the packages. Run it with python get-pip.py --no-index --find-links=./packages.

Can I use this method to install the Python interpreter itself?

No. Pip manages libraries only. For the interpreter, download the official installer executable (Windows) or the appropriate .deb/.rpm packages (Linux) and transfer them separately.

How do I know what dependencies a package needs before downloading?

The pip download command resolves this automatically by recursively downloading everything required. Alternatively, check the package’s “Dependencies” section on its PyPI page for a complete list.

Where can I find .whl files manually?

They are available on pypi.org under the “Download files” tab on each library’s page, clearly labeled with their compatible Python version and operating system.

Is it possible to update packages offline?

Yes. The process is identical. Download the new version on the connected machine and run pip install --upgrade --no-index --find-links=./packages package-name on the target machine.

What does the –no-deps flag do?

It tells pip to skip installing dependencies. Use this only when you are absolutely certain all required dependencies are already installed in the environment, otherwise the package may fail at runtime with import errors.

Does this method work on macOS?

Yes. Pip behaves identically across all platforms. Only the internal binary format inside the wheel file changes depending on the operating system, which is why downloading for the correct platform matters.

Share:

Facebook
WhatsApp
Twitter
LinkedIn

Article content

    Related articles

    Copiando e movendo arquivos com Python usando shutil
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    Copy and Move Files with Python shutil

    Learn how to copy and move files with Python shutil using copy, copy2, move, copytree, rmtree, error handling, and an

    Ler mais

    Tempo de leitura: 6 minutos
    19/05/2026
    Compactando arquivos ZIP automaticamente com Python
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    How to Create ZIP Files with Python in 2 Minutes

    Learn how to create ZIP files in Python with zipfile, compress folders, filter extensions, handle errors, and build a ready-to-run

    Ler mais

    Tempo de leitura: 7 minutos
    19/05/2026
    Como acelerar código Python usando lru cache
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    Speed Up Python Code with @lru_cache

    Learn how @lru_cache speeds up Python code with memoization, maxsize, cache_info, cache_clear, API caching, and cases where it should be

    Ler mais

    Tempo de leitura: 7 minutos
    19/05/2026
    Monitoramento de pastas em tempo real com Python Watchdog
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    Monitor Folders in Real Time with Python Watchdog

    Learn how to monitor folders in real time with Python Watchdog using Observer, handlers, file filters, permissions, logging, and a

    Ler mais

    Tempo de leitura: 7 minutos
    19/05/2026
    Redimensionamento de imagens com Pillow em Python
    Libraries and Modules
    Foto de perfil de Leandro Hirt da Academify

    How to Resize Images with Pillow in Python

    Learn how to resize images with Python's Pillow library. This guide covers basic resizing, aspect ratio preservation, the thumbnail method,

    Ler mais

    Tempo de leitura: 9 minutos
    12/05/2026