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
Share this post
Related Posts
UV
UV unified Python package manager: Rust-based replacement for pip, venv, pip-tools, developed by Astral (Ruff).
Precedence of Logical Operators
Logical operator precedence: NOT (highest), AND (medium), OR (lowest) with Python code examples showing order.
4 Ways of Serving Static Files in Django
Four Django static file serving methods: dev server, Whitenoise, Nginx, and Amazon S3 cloud storage comparison.
LeetCode Blind 75 Golang Solutions Part I
Golang solutions to LeetCode Blind 75 Array/Hashing problems: Contains Duplicate and Valid Anagram with 100% runtime.