question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Forgetting to source a virtualenv is more of an issue since pip 20

See original GitHub issue

What’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:open
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
uranusjrcommented, Feb 25, 2021

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

pip install foo  # This only works inside a virtual environment.
pip install --user foo  # This installs to the user base, not changed.
pip install --global foo  # This installs to the installation base.
0reactions
uranusjrcommented, Feb 27, 2021

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 setting global = true in a config file? Environment variable?)

Read more comments on GitHub >

github_iconTop Results From Across the Web

virtualenv --no-site-packages and pip still finding global ...
This was the issue for me: I had aliased pip to a specific path to the global pip, which was not being overridden...
Read more >
Rebuilding a Virtualenv - PythonAnywhere help
1) Use a requirements.txt file to record what packages you're using¶ ; Save the list of packages to a requirements file. pip freeze...
Read more >
virtualenv 1.10.1 - PyPI
When using pip to install virtualenv, we advise using pip 1.3 or greater. Prior to version 1.3, pip did not not download from...
Read more >
ModuleNotFoundError: No module named 'virtualenv' in Python
Not having the virtualenv package installed by running pip install virtualenv . · Installing the package in a different Python version than the ......
Read more >
Code more, debug less with virtual environments in Python
The same problem extends to individual Python modules. You might install version Z of the ExamplePyMod module, develop your code, and post your ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found