How to install a venv in Python without network connection

In some cases you have to replicate a Python project on a computer without internet connection. In these cases you must not simply copy the venv folder.

Requirements for this process: the project, a memory mass storage, another computer with internet connection.

First of all, you have to to install Python on the offline machine. Now let’s go deeper into the venv replication process.

Take a look to the requirements.txt file of the project where all the dependencies are declared. Keep in mind: this file might not contain all the recursive dependencies.

Now we are going to download all the dependencies: jump into the root of the project and launch the following command from the terminal:

pip download <package-name/version>

For example:

pip download itsdangerous==2.0.1

Collecting itsdangerous==2.0.1
  Using cached itsdangerous-2.0.1-py3-none-any.whl (18 kB)
Saved ./itsdangerous-2.0.1-py3-none-any.whl
Successfully downloaded itsdangerous

We can see that a wheel file or a compressed package has been now downloaded with all the recursive dependencies if required.

Repeat this process for the packages declared in the requirements file and you will have a pool of libraries, ready to be copied into the new project.

If you have downloaded all the packages is now time to create a new fresh venv into the project in the offline computer:

python3 -m venv ./venv/

Copy all the python libraries downloaded into a directory inside the project and jump inside.

We have now to identify all the packages without recursive dependencies themselves. Let’s install wheels with the following command:

pip install xyz.wheel

or unpack and run the following command for compressed dependencies packages:

pip install ./dependency/folder/

Repeat the process for all the packages and you will have replicated the virtual environment on an offline machine


This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.