pip: pip install -U does not remember whether a package was installed with --user

If you do

pip install --user dist
pip install -U dist

then the upgrade will uninstall the original installation from the user site-packages and install the upgraded version in the system site-packages. It should not do this, but rather should remember where the package being upgraded was located, and reinstall to the same location.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Reactions: 2
  • Comments: 15 (11 by maintainers)

Most upvoted comments

Ohk. 💡 There seems to be consensus on that behavior them. I have an idea/proposal…

AFAIK, there are 3 possible schemes for packages:

  • “system” - for system/global packages (--system)
  • “user” - for packages installed in user space (--user)
  • “local” - for virtualenv packages (--local)

pip enforces a “working” scheme on every run. Outside a virtualenv, the default working scheme would be “system” (It should really be “user”, that’s another issue #1668). Inside a virtualenv, the default working scheme should be “local”. Passing --system or --user or --local overrides the working scheme.

Only packages in the same scheme as the working scheme can be modified. By modifying, I mean installing or uninstalling a package. Trying to modify a package in a different scheme is not allowed and pip would print a message and error out.

So, modifying a package in system scheme with a “user” working scheme is not allowed. Nor is modifing a package in user scheme with a “system” working scheme. Niether are the other permutations with “local”.

I think this results in a pretty simple behaviour model.

Any comments?

(editted)

It’s not so clear this is a user mistake. Why does pip uninstall package installed using user scheme during pip install -U dist while there’s no --user option given? This is very bad UX. The only sane behavior would be to operate on packages installed in user scheme only if --user was passed.