on WSL running ubuntu 24.04, running python 3.11.7, arm64
pip doesn’t work now resulting in error: externally-managed-environment
the following doesn’t work either
sudo apt install dash
or sudo apt install python3-dash
Any suggestions?
on WSL running ubuntu 24.04, running python 3.11.7, arm64
pip doesn’t work now resulting in error: externally-managed-environment
the following doesn’t work either
sudo apt install dash
or sudo apt install python3-dash
Any suggestions?
Hello @retro_afw,
Welcome to the community!
It sounds like you need to download pip for some reason…
PIP doesn’t work with latest ubuntu and Python, due to the way they manage external installs. I think this is to “container-ise” the impact on the core systems.
You can always install it as a venv, then install python3-pip through apt install?
Hi,
I will provide a bit more info:-
pip install dash
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.
See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
sudo apt install pipx
pipx ensurepath
/home/.local/bin
reload terminal
pipx install dash
installed package dash 2.15.0, installed using Python 3.11.7
These apps are now globally available
- dash-generate-components
- dash-update-components
- renderer
python3
Python 3.11.7 (main, Dec 8 2023, 14:22:46) [GCC 13.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
import dash
Traceback (most recent call last):
File “”, line 1, in
ModuleNotFoundError: No module named ‘dash’
Note: this virtual environment is new to me, not sure how I can import as you can see from above.
I think in this reference, they are referring to x
as the python release.
Running a venv in ubuntu, you should be able to do this:
python3 -m venv path/to/venv
source path/to/venv/bin/activate
pip3 install dash
Where path to venv is wherever you want the virtual environment to run.
Raspberry pi website provided a venv workaround
This error is generated because you’re trying to install a third-party package into the system Python. A long-standing practical problem for Python users has been conflicts between OS package managers like apt
and Python-specific package management tools like pip
. These conflicts include both Python-level API incompatibilities and conflicts over file ownership.
Therefore from Bookworm onwards, packages installed via pip
must be installed into a Python virtual environment using venv
. A virtual environment is a container where you can safely install third-party modules so they won’t interfere with, or break, your system Python.
An alternative method to creating a virtual environment for each of your Python projects is to create a single virtual environment for your user account, and then activate that environment before running any of your Python code. This approach may be preferred if you commonly install the same set of modules for each project, and don’t want to have to bother creating individual Python environments for each project, essentially just duplicating your environment.
$ python -m venv ~/.env
$ source ~/.env/bin/activate
(.env) $pip install dash
$python3
>>>import dash
the above works.
I just need to remember to deactivate afterwards
Glad you got it working.
Yes, this is always an issue and can cause issues if you install different versions of python, etc.
ran into the “externally-managed-environment” error while trying to install Dash, but I found a workaround from the Raspberry Pi website.
This error is typically caused by trying to install a third-party package into the system Python. It happens due to conflicts between OS package managers like apt and Python-specific package management tools like pip. These conflicts often lead to incompatibilities and file ownership issues.
Starting from Bookworm, packages installed via pip must be done inside a Python virtual environment using venv. A virtual environment is essentially a container that allows you to safely install third-party modules without interfering with your system Python.
You can create a single virtual environment for your user account, and activate it before running any Python code. This is useful if you regularly install the same set of modules for different projects and don’t want to create individual environments for each one.
Here’s the process:
Blockquote python -m venv ~/.env source ~/.env/bin/activate
(.env) pip install dash python3import dash
This worked perfectly for me. Just remember to deactivate the environment when you’re done:
Blockquote $ deactivate
If you’re new to setting up Python environments, check out this helpful guide on how to install Python and pip on Ubuntu: Install Python and pip on Ubuntu. It’s been a lifesaver for me!