Serdar Torlak
Posted on May 18, 2024
I am not sure why this happens but each time i install a new linux system and i try to pip install a python library i am getting the following warning/error message:
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
So if you are having the same problem, here is how to fix it:
First of all make sure you have Pip installed for your linux. Here i'll go with Ubuntu, you can change the command line according to your Linux system:
$ sudo apt update
$ sudo apt install python3-pip
Now check to verify the installation of Pip:
pip3 –version
You're ready to fix the problem for installing modules/librarires for Python. Type the following to your terminal:
$ python3 -m pip config set global.break-system-packages true
You can now install pip packages however use it carefully as there is always a chance to break your linux system!
Posted on May 18, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.