Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Post History

50%
+0 −0
Q&A Why does Pip display "error: externally-managed-environment", and what can I do about it?

tl;dr: There's a few ways to bypass this: For all users on the machine: Get rid of /usr/lib/python3.foo/EXTERNALLY-MANAGED. To prevent your package manager from adding it back, replace it with a...

posted 6mo ago by matthewsnyder‭  ·  edited 6mo ago by matthewsnyder‭

Answer
#4: Post edited by user avatar matthewsnyder‭ · 2024-06-28T22:51:31Z (6 months ago)
  • There's a few ways to bypass this silliness:
  • * For all users on the machine: Get rid of `/usr/lib/python3.foo/EXTERNALLY-MANAGED`. To prevent your package manager from adding it back, replace it with a dummy/empty file. (you'll have to do this again for every minor Python version)
  • * For your user only: Create or edit `~/.config/pip/pip.conf` so that it contains:
  • ```
  • [global]
  • break-system-packages = true
  • ```
  • * For one shell session: Set the environment variable `PIP_BREAK_SYSTEM_PACKAGES=1` (you can configure your shell to always set this)
  • * For one command only: Pass `--break-system-packages` to pip.
  • Why?
  • A few years ago, Python devs decided that simply installing packages with `pip install foo` is bad and evil. So now they want you to wait for your distro to repackage it (for example, instead of `pip install requests` you're supposed to do [`pacman -S python-requests`](https://archlinux.org/packages/extra/any/python-requests/)), or create a venv and install everything in there.
  • I won't reproduce the Python devs' rationale here; it is readily available in PEP 668 and other answers here. But if you want to follow the spirit of their decision with less inconvenience, your best bet is probably to create a new (non-system) Python with https://github.com/pyenv/pyenv and make that the default for your shell.
  • **tl;dr:** There's a few ways to bypass this:
  • * For all users on the machine: Get rid of `/usr/lib/python3.foo/EXTERNALLY-MANAGED`. To prevent your package manager from adding it back, replace it with a dummy/empty file. (you'll have to do this again for every minor Python version)
  • * For your user only: Create or edit `~/.config/pip/pip.conf` so that it contains:
  • ```
  • [global]
  • break-system-packages = true
  • ```
  • * For one shell session: Set the environment variable `PIP_BREAK_SYSTEM_PACKAGES=1` (you can configure your shell to always set this)
  • * For one command only: Pass `--break-system-packages` to pip.
  • (there used to be some thoughts here on why this has become necessary in recent years, but it proved controversial and I removed it)
#3: Post undeleted by user avatar matthewsnyder‭ · 2024-06-28T22:50:19Z (6 months ago)
#2: Post deleted by user avatar matthewsnyder‭ · 2024-06-28T22:33:07Z (6 months ago)
#1: Initial revision by user avatar matthewsnyder‭ · 2024-06-25T20:40:20Z (6 months ago)
There's a few ways to bypass this silliness:

* For all users on the machine: Get rid of `/usr/lib/python3.foo/EXTERNALLY-MANAGED`. To prevent your package manager from adding it back, replace it with a dummy/empty file. (you'll have to do this again for every minor Python version)
* For your user only: Create or edit `~/.config/pip/pip.conf` so that it contains:
    ```
    [global]
    break-system-packages = true
    ```
* For one shell session: Set the environment variable `PIP_BREAK_SYSTEM_PACKAGES=1` (you can configure your shell to always set this)
* For one command only: Pass `--break-system-packages` to pip.

Why?

A few years ago, Python devs decided that simply installing packages with `pip install foo` is bad and evil. So now they want you to wait for your distro to repackage it (for example, instead of `pip install requests` you're supposed to do [`pacman -S python-requests`](https://archlinux.org/packages/extra/any/python-requests/)), or create a venv and install everything in there.

I won't reproduce the Python devs' rationale here; it is readily available in PEP 668 and other answers here. But if you want to follow the spirit of their decision with less inconvenience, your best bet is probably to create a new (non-system) Python with https://github.com/pyenv/pyenv and make that the default for your shell.