-
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 should not destroy instead of upgrade itself on Windows #9395
Comments
pip 20.3 and later no longer fail in an unusable state. It still suggests |
|
After some thinking I was able to reproduce this. It only works if the venv is on the same volume as %TEMP%. It does not work if the venv is:
Moving files across volumes does not work on Windows, of course, and procmon shows that whatever method pip uses to move the wrapper instead tries copy-then-delete, and pip does not even notice it is setting itself up to fail. |
If you aren't running the terminal as Administrator, this still happens... new issue or should I track it under this one? pip 21.0.1
|
I do not think this is the same bug. This one is about That said, I'm not sure what is going on there. You obviously have write permission on |
Hi there. Here is a fix at #10454. Another quick fix is to run the command in administrator shell/user that have write access to c:\daten\venv\scripts\ as stated in the error message. |
Hello, unfortunately neither your PR nor your suggestion of admin rights will fix this issue. It has nothing to do with file permissions, not least because (as you can clearly see in my first example) I create the venv immediately before attempting to upgrade pip. Obviously I have all the permissions I need on the files in the venv. The problem here is that the venv is on a different volume from the executing user's %TEMP%, and pip does not check for that. It attempts to move the pip.exe wrapper to %TEMP% so it can create a new one for the updated version, but Windows does not let you move (e.g. I suspect that pip uses existing library code, such as There are two possible fixes that I can imagine. One is to rename the wrapper in the same directory rather than attempt to move it to %TEMP%; renaming an open file is possible. The other is to check whether %TEMP% is on the same volume, and if it is not, bail out with a useful error message that directs the user to |
@chrullrich thanks for clarification of your case. I think i will make further research about access problems. |
Environment
Description
pip upgrade pip
in a venv on Windows will inevitably end in failure to delete thepip.exe
wrapper, which is a running process. The next line of output uselessly suggests using--user
. The correct approach is to runpython -m pip install -U pip
instead, but the user is not told this, and at the time of the error the pip installation is already gone anyway.There are two ways to recover, the faster and far less discoverable one is
python -m ensurepip
, the other is to nuke the venv and start over.Upgrading pip in the same way in a system-wide installation also throws the error, but appears to successfully upgrade itself first. I suspect it upgrades the Python bits of itself first and only then fails to recreate the executable wrapper.
Expected behavior
pip should probably do the same in a venv that it does in the system-wide installation, i.e. upgrade its innards first, then fail to update the executable wrapper (because it is somewhat version-independent). If that is not possible, at least it should not uninstall (most of) itself before failing, but exit early and with a comprehensible error message that points out the correct command to run.
(Better yet, it should re-run itself using the correct command line, but that interferes with returning the correct exit code. Oh, exec(), how we miss you.)
How to Reproduce
Output:
The text was updated successfully, but these errors were encountered: