python virtual env for package local installation
mouse 91 · person cloud · link
Last update
2024-06-02
2024
06-02
« — »

The presence of the file /usr/lib/python*/EXTERNALLY-MANAGED means:

  • Conflict prevention: Ensures that Python packages installed by the system package manager are not overwritten or modified by pip installations.
  • System stability: Maintains the consistency and stability of the Python environment by avoiding uncontrolled modifications.

running pip install pkg-name does nothing but printing error: externally-managed-environment.

You can install a package locally in a safe way without breaking you system via the venv package:

1
2
3
4
5
6
7
8
9
# install the `venv` package and create a local virtual environment folder
sudo apt install python3.11-venv
python3 -m venv ~/.pip3venv

# install a package into it
~/.pip3venv/bin/pip install -U package-name

# call its own binary
~/.pip3venv/bin/package-name

Source: stackoverflow