Offline Python Packages Installation
Imagine a senario that we need to install a particular Python version together with all the dependencies on a computer with no internet connection, or we need to simply move a Python venv to another machine without internet.
I. Create a requirements.txt
(venv) [...]$ mkdir pkgs
(venv) [...]$ cd pkgs
(venv) [...]$ pip freeze > requirements.txt
II. Download the pip packages on your pc with the requirements.txt
(venv) [...]$ pip download -r requirements.txt
# You must take care to use the same python version 3.8.6..., maybe the same pip version, too. You can create a venv to do that to save time.
III. Copy the pkg folder (Inside it will be all packages (files with .whl extension usually) and the requirements.txt file) into the PC with no internet connection.
IV. Create a new virtual environment and install packages on the remote computer
(venv) [...]$ cd /the/path/to/pkgs
(venv) [...]$ pip install -r requirements.txt --no-index -f .
# The dot in the end is the path where the packages are.
# or
(venv) [...]$ pip install -r requirements.txt --no-index -f /the/absolute/path/to/pkgs
# --use-pep517