dotrun icon indicating copy to clipboard operation
dotrun copied to clipboard

"error: externally-managed-environment" on macOS 14.3.1

Open gerwitz opened this issue 1 year ago • 3 comments

Following the installation instructions on macOS 14.3.1 (on Apple silicon) leads me to the error below. Before I follow pip3's guidance and try pipx, I thought I should confirm this is a sensible remediation.

gerwitz@Umwelt design.ubuntu.com % sudo -H pip3 install dotrun
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-brew-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.
    
    If you wish to install a non-brew 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.

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.

gerwitz avatar Mar 17 '24 20:03 gerwitz

Seems like more people are started to be affected by this.

This seems like some new feature of Python environments to provide more security for the OS-maintainer Python packages. https://packaging.python.org/en/latest/specifications/externally-managed-environments/#externally-managed-environments

I don't know enough about Python envs to suggest a solution, seems like official answer is to use pipx.

I guess we would need to test if dotrun works with pipx and update our install instructions.

bartaz avatar Apr 10 '24 13:04 bartaz

Adding a +1 here, as I also just got this error on a Xubuntu 24.04 install. I was also unable to immediately resolve this using pipx, as this becomes a bit of a rabbit hole in which pipx also needs access to Docker, which then also has to be installed via pipx, etc.

I resolved using an unpleasant command line flag: sudo pip3 install dotrun --break-system-packages, but this obviously isn't optimal.

pastelcyborg avatar Jul 08 '24 17:07 pastelcyborg

pipx is a safe way to install and run dotrun, so I will update the README to include installation instructions with pipx and make an install script so we can simply do this to install pipx + dotrun:

curl -L https://raw.githubusercontent.com/canonical/dotrun/main/install.sh

goulinkh avatar Aug 08 '24 11:08 goulinkh

The latest of version of dotrun 2.4.0 supports pipx, installation instructions are updated.

goulinkh avatar Aug 19 '24 12:08 goulinkh