Forgetting to source a virtualenv is more of an issue since pip 20
See original GitHub issueWhat’s the problem this feature will solve?
Since pip 20, doing a --user
install when the main site-packages directory is not writeable and user site-packages are enabled is the default.
When working with virtualenv
, this makes the common (for me) mistake of forgetting to source the virtualenv much more of an issue. I had this happen a couple of times since upgrading. It took me quite some time to figure out the issue, and some time to clean up my system.
Before, when mistakenly running pip install
outside the virtualenv, it would fail because of the required root privileges. Now it succeeds and modifies the user site-packages. I understand this is the expected behavior, since the user forgot to source.
Describe the solution you’d like
I agree with the rationale behind #1668. I am not too sure about the best solution here. My own workflow almost never requires to use pip outside of a virtualenv, but I am unsure about how common this is. I believe, for example, that this behavior would achieve consistency regarding the installation site:
pip install something # virtualenv only
pip install --user something # user site-packages
pip install --root-user something # main site-packages
I understand this would be yet again a breaking change, so doing nothing might work too 😉 Thanks for the great work on pip!
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
I wonder if I should use this issue as a cue to bring up the conversation to completely disable pip installing into the global Python installation 😃 There are very old issues for this, but tl;dr
One wrinkle to this is whether
--global
should automatically switch to--user
if the global prefix is unavailble. This would also require a rethought on #2081 to be designed properly. (e.g. can you--global
in a virtual environment? What about settingglobal = true
in a config file? Environment variable?)