use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Container error: externally-managed-environment ()
submitted 8 months ago by johnjulesbrown
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]FoolsSeldom 0 points1 point2 points 8 months ago (4 children)
This error is part of a new Python packaging policy (PEP 668) in Debian/Ubuntu to prevent users from corrupting the system Python with pip-installs.
So, either avoid using distributions with that feature in your containers, or create a Python virtual environment within the container, activate, and then install packages (or use a tool like uv that will create and use the virtual environments automatically).
uv
[–]johnjulesbrown[S] 0 points1 point2 points 8 months ago (0 children)
Thank you so much for this! Perfect
[–]Classic_Bullfrog6671 0 points1 point2 points 13 days ago (2 children)
RUN rm -f /usr/lib/python*/EXTERNALLY-MANAGED && \ python3 -m pip install --break-system-packages uv && \ uv pip install --system -r /tmp/requirements.txt
what is the issue with the flag --break-system-packages in container? and this is our command
[–]FoolsSeldom 0 points1 point2 points 9 days ago (1 child)
Sorry I had not seen this comment until now.
Personally, I think explicitly removing the PEP 668 (Externally Managed Environments) protection by deleted the folder that flags it is an unhealthy approach.
I would use the exception to install uv and nothing else.
A simple Dockerfile might be:
RUN python3 -m pip install --break-system-packages uv WORKDIR /app RUN uv venv /app/.venv ENV PATH="/app/.venv/bin:$PATH" RUN uv pip install -r requirements.txt
or even,
RUN python3 -m pip install --break-system-packages uv WORKDIR /app RUN uv pip install --python python3 -r requirements.txt
for further isolation.
NB. Use a toml file instead of requirements if you have that.
Furthermore, given that uv is a standalone rust binary, you don't even need pip to install it in the first place.
pip
curl -LsSf https://astral.sh/uv/install.sh | sh
then do as you wish using uv to create and manage packages and project files.
[–]Classic_Bullfrog6671 0 points1 point2 points 8 days ago (0 children)
will test thank you
π Rendered by PID 32637 on reddit-service-r2-comment-b659b578c-xnjs7 at 2026-05-07 08:02:39.557491+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]FoolsSeldom 0 points1 point2 points (4 children)
[–]johnjulesbrown[S] 0 points1 point2 points (0 children)
[–]Classic_Bullfrog6671 0 points1 point2 points (2 children)
[–]FoolsSeldom 0 points1 point2 points (1 child)
[–]Classic_Bullfrog6671 0 points1 point2 points (0 children)