Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #197408

Re: Pip installs to unexpected place

From Thomas Passin <list1@tompassin.net>
Newsgroups comp.lang.python
Subject Re: Pip installs to unexpected place
Date 2025-04-16 12:50 -0400
Message-ID <mailman.14.1744823411.3008.python-list@python.org> (permalink)
References (1 earlier) <CAN06=CxPNLHtr_sdgphR2jrN1V+WbB8wZDJdbvfEDb-MYtmPHA@mail.gmail.com> <bbe32f47-13d2-459c-af22-4e0e37834091@tompassin.net> <mailman.9.1744749213.3008.python-list@python.org> <m681ukFimrnU2@mid.individual.net> <d9974802-78f3-403c-9e69-077494d4e940@tompassin.net>

Show all headers | View raw


On 4/15/2025 5:38 PM, rbowman via Python-list wrote:
> On Tue, 15 Apr 2025 14:12:19 -0400, Thomas Passin wrote:
> 
>> On Linux, at least, it's standard for pip to install into the user's
>> site-packages location if it's not invoked with admin privileges - even
>> without --user. Pip will emit a message saying so. Well, that used to be
>> true but nowadays Pip wants you to use the --break-system-packages flag
>> if you want to insist on installing into the system's Python install,
>> even if it's going to go into --user. I'm not sure if the restriction
>> will be in place given that the OP built his own Python version.
> 
> Is that pip or a distro's version of pip? On Fedora I get the message
> about defaulting to user. On Ubuntu I get a message to use a venv or if I
> really want a global install to use something like 'pip install python3-
> black'. Ubuntu's is pip 24.2, Fedor's is 24.3.1 but neither of them show
> '--break-system-packages' in --help.

The behavior is specifed in

https://packaging.python.org/en/latest/specifications/externally-managed-environments/#externally-managed-environments

Exactly how pip works and what messages it emits are specified by this 
document, and the details depend on how the distro's packagers configure 
it.  For example, here is a bit of the spec:

"Before a Python-specific package installer (that is, a tool such as pip 
- not an external tool such as apt) installs a package into a certain 
Python context, it should make the following checks by default:

     Is it running outside of a virtual environment? It can determine 
this by whether sys.prefix == sys.base_prefix.

     Is there an EXTERNALLY-MANAGED file in the directory identified by 
sysconfig.get_path("stdlib", sysconfig.get_default_scheme())?

If both of these conditions are true, the installer should exit with an 
error message indicating that package installation into this Python 
interpreter’s directory are disabled outside of a virtual environment.

The installer should have a way for the user to override these rules, 
such as a command-line flag --break-system-packages. This option should 
not be enabled by default and should carry some connotation that its use 
is risky."

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar


Thread

Re: Pip installs to unexpected place Thomas Passin <list1@tompassin.net> - 2025-04-15 14:12 -0400
  Re: Pip installs to unexpected place rbowman <bowman@montana.com> - 2025-04-15 21:38 +0000
    Re: Pip installs to unexpected place Thomas Passin <list1@tompassin.net> - 2025-04-16 12:50 -0400

csiph-web