-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pip install --user tries to uninstall from system site-packages #4337
Comments
@piotr-dobrogost - Yes, I managed to do what I wanted using this:
So there is certainly a workaround. The question from my side remains -- is this intended / good behaviour by pip? |
It's intended, because Python (not pip, but Python's core import mechanisms) doesn't really like multiple versions of a package on Basically, pip uninstalls older versions precisely to avoid this issue. The |
This is a recent change in behaviour from pip though, no? Was it very recently? Personally I'm fine with the old or new behaviour. So just close this issue? |
TBH, I'm not sure about that. I never put packages in both places, so I can't honestly say from my own experience, and I'd have to trawl the changelogs to see if there was any specific mention. I'm not sure if you're the first one to be caught by this - I know I've explained the "you shouldn't have multiple versions on sys.path" issue before, but I can't recall if it was in relation to this or some other scenario. If you propose a change to pip, leave the issue open and your suggestion can be looked at - but my personal view is that the current behaviour is fine (which I think you're OK with). If you think a doc change would help, we'd be very grateful for a PR with your suggested rewording. If we missed including something in the changelogs, then it's probably water under the bridge now (I don't know if we have a policy on retroactively updating the changelog). Going forward, the changelog is definitely where you'd keep up to date with what's changed as new versions come out. |
I don't know if it's a good idea to start uninstalling stuff when a user says install. My guess is that there will be surprises and gotchas either way. But if that's the intended behaviour, fine. I'm still surprised I haven't encountered this before and didn't have to use I had a look at the docs and found it hard to find a description of the behaviour of pip.
Searching for
It's not obvious to me from that description that pip will basically always try to uninstall the given package I'm trying to install, if it's anywhere on my Or maybe there could be another mention of this behaviour and of @pfmoore and @piotr-dobrogost - Close issue now? Or do you agree that some docs edits (which ones exactly) could be made to improve the description? |
@piotr-dobrogost seems to have found some of the history (although for some reason I can only see his comment in email, not here). Looks like it is changed behaviour, and was requested by some people. Agreed it should be documented better (but I don't understand the original details of the change, so can't really say how to describe the current situation). Sorry, I can't really offer more help. |
I agree behavior of |
@pfmoore |
Ah, that's what happened! Sorry. Github emails don't reflect edits, I've been bitten by that before... |
Agreed what happens is unintuitive, and I wouldn't be opposed if someone argued it's wrong. However, as I noted, having 2 different versions in system site-packages and user site-packages could cause issues. We can't win either way - someone's going to be bitten by unintuitive behaviour no matter what we do. Ideally, someone should review this whole area and propose a resolution - which may be documentation only or may include behaviour changes. But without any funded support for pip, that's not likely to happen unless a user who's actually experiencing issues steps up to do the work. |
(...) having 2 different versions in system site-packages and user site-packages could cause issues. |
Well, yes - but that's not how Python works. We can happily reject bug reports as "not a pip issue", but that still leaves us with confused users. If you want to raise a bug against Python, I guess you could. I doubt it'd be easy to get it fixed, though. |
The behaviour I had for the past years and got used to was that I probably won't participate further in discussions and don't have time to contribute code or docs fixes to pip, sorry. So just to summarise, from the user perspective, my main wish here is to get more information about how pip works and when new releases come out, to explain better what behaviour changed (via a "What's new page" or blog post). |
I see, you are referring here to the contrived example with |
They probably assumed people wouldn't install in both system packages and user packages. Or maybe they just didn't think of this issue. Who knows? And yes, my example was contrived. However, I think (although I can't be sure, or provide references) that we've had real issues as a result of this. On a purely personal note, I only use the system site-packages (I'm on Windows, and I have a per-user install of Python 3.6, so this doesn't affect anything else like a system package manager) and virtualenvs, so the issue doesn't affect me either way (apart from needing to provide support to people on issues like this). So I'll leave this discussion now to be taken further by people who are affected. |
@dstufft |
@piotr-dobrogost It works fine if you install a given package in only user or system location, not in both. Sorry I may have misunderstood as I assumed that you realised that. It's only when you try to install different versions the same distribution in both places that there's any possibility of an issue. |
@piotr-dobrogost My apologies. Over on distutils-sig, @ncoghlan corrected me on this. Apparently the import system does protect against multiple version clashes like this. At least to the extent that the first version that's on sys.path will always "win", so there's never going to be inconsistent imports like I described. I couldn't find anything in the docs about whether the user scheme comes before or after the system scheme in sys.path. I assume it comes before, so that user installs take precedence over system installs, but I've been bitten once today by not testing my claims, so I'll just say "I assume" here... :-( |
Yea, it goes:
In each of those, I think any |
Can you share link to this?
Ok. In that case we are back to pip's behavior and my earlier statement that pip shouldn't care what's already installed globally when installing in user scheme. @dstufft Would you agree? |
#4466 is possibly a dupe. Reading the pip docs (https://pip.pypa.io/en/stable/user_guide/#user-installs), it seems very clear to me as a user that:
means So this appears to be a regression in 9.x and in contradiction with the docs. As far as I understand it, the whole point of the user scheme is that users may not have control over system packages, and may not be able to uninstall anything from there. Even if they did have permission, one user installing a new version of a package in their user namespace, triggering an uninstall from system |
Globally installed packages (in system site-packages) should be ignored (...) |
@piotr-dobrogost but if I use
When the first two of four rules for the way a feature operates are completely wrong, and the remaining rules are basically just sanity checks preventing action where it wouldn't make sense anyway, it seems there's not much point in supporting the user scheme at all. I'm a bit confused though, about why I'm pretty sure this was working as expected and as documented before, but is now completely broken. |
Related #4575 |
@cdeil would it be an improvement to have pip send a message on |
The --ignore-installed flag isn't a exact fix for the problem here. #4575 and #1668 are the proper fixes for this and will need someone to either do it or fund work to get it done. (https://wiki.python.org/psf/Fundable%20Packaging%20Improvements) |
Ha ha, I haven't used But re-reading the discussion above: yeah, I would still say a
Well, yes, if that is an easy addition, and the real fix and change in behaviour of |
Description:
I've been a happy user of pip for a while, thank you for all your work!
Now (possibly after a recent pip update), the bahaviour has changed and
from a source folder in a Python project I work on (Gammapy) tries to uninstall a stable 0.5 version of Gammapy I have in the Macports site-packages.
I wasn't expecting pip to do this uninstall and it's not clear to me from the pip 9.0 and 9.0.1 release notes that this is an intended change in behaviour.
Is this a bug or am I doing it wrong?
What's the workaround?
What I've run:
The text was updated successfully, but these errors were encountered: