This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: venv module clashes with pip --user ... improve coordination.
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: FFY00, bernd.wechner
Priority: normal Keywords:

Created on 2020-10-10 07:24 by bernd.wechner, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg378368 - (view) Author: Bernd Wechner (bernd.wechner) Date: 2020-10-10 07:24
When developing Python software it is highly discouraged to install python modules globally (risking adverse impacts upon the underlying OS where if has Python dependencies).

Project by project this typically done with venvs (and the venv module)

User by user it is typically done with the --user option.

In fact to make impacting system libraries less likely a pip.conf file can be written that contains:

user = true

I suspect this is an increasingly common practice which means pip installs are on a local user profile not into system dirs. 

Alas when in a venv now, pip bombs with a detected conflict:

ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

This was explored with pip here:

It turns out that pip can be made to function by overriding this setting in the venv. That is depositing a pip.conf in the vend dir that contains:

user = true

and all is good once more. In the activated venv pip now works again. 

This is at its core a coordination issue then between the venv module and pip and the point to fix it seems most likely to be in the venv module which, knowing that this conflict can exist can as a safety precaution simply always, or optionally, write a pip.conf into newly created venvs that disables the user options. Given pip won't work in a venv if that option is enabled and we know that up front.

Why fix it in the venv module? Because discovering the cause of this conflict was time consuming and disorienting, poor UX by any definition and it should ideally not arise or if it must have an easily discovered fix. 

This is a request to prevent it arising altogether in newly created venvs.
Date User Action Args
2022-04-11 14:59:36adminsetgithub: 86156
2020-10-12 12:52:23FFY00setnosy: + FFY00
2020-10-10 07:24:45bernd.wechnercreate