Skip to content
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

Upgrade pip deletes pip when executing from the Scripts folder #10505

Closed
1 task done
Temmay opened this issue Sep 25, 2021 · 2 comments · Fixed by #10560
Closed
1 task done

Upgrade pip deletes pip when executing from the Scripts folder #10505

Temmay opened this issue Sep 25, 2021 · 2 comments · Fixed by #10560
Labels
C: upgrade The logic of upgrading packages OS: windows Windows specific type: bug A confirmed bug or unintended behavior

Comments

@Temmay
Copy link

Temmay commented Sep 25, 2021

Description

When I upgrade pip using a freshly installed Python 3.9.7 environment in a command prompt from the Scripts folder, the upgrade fails, the Scripts folder is emptied and the pip module is removed as well.

Below you will find "Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird". This translates to "The process cannot access the file, since it is used by another process".

I am used to do all upgrades of pip modules from within the Scripts folder. Because of this I use "..\python.exe" to run Python from there.
When I execute "python.exe -m pip install -U pip" from the Python39 folder, then the upgrade succeeds on a fresh Python installation. So it points to as if pip tries to delete the Scripts folder and then rename the ~cripts folder that it has created during the install process. Why does pip not copy the contents of ~cripts to the emptied folder Scripts? Such my kind of upgrading pip would work as it used to work earlier.

Expected behavior

A normal upgrade of pip from version 21.2.3 to 21.2.4 (or whatever is the most recent version).

pip version

21.2.3

Python version

3.9.7

OS

Windows 10

How to Reproduce

  1. Get python-3.9.7-amd64.exe from https://www.python.org/downloads/
  2. Install it in "D:\Programme\Python\Python39".
  3. Open a command prompt, e. g. Windows command prompt or ConEmu (x64) (I use the latter).
  4. Navigate to folder "D:\Programme\Python\Python39\Scripts".
  5. Execute "..\python.exe -m pip install -U pip".

Output

Microsoft Windows [Version 10.0.19043.1237]

<UserAccountName>@<DeviceName> D:\Programme\Python\Python39\Scripts
$ pip list --outdated
Package    Version Latest Type
---------- ------- ------ -----
pip        21.2.3  21.2.4 wheel
setuptools 57.4.0  58.1.0 wheel
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the 'D:\Programme\Python\Python39\python.exe -m pip install --upgrade pip' command.

<UserAccountName>@<DeviceName> D:\Programme\Python\Python39\Scripts
$ ..\python.exe -m pip install -U pip
Requirement already satisfied: pip in d:\programme\python\python39\lib\site-packages (21.2.3)
Collecting pip
  Downloading pip-21.2.4-py3-none-any.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 2.2 MB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.2.3
    Uninstalling pip-21.2.3:
ERROR: Could not install packages due to an OSError: [WinError 32] Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird: 'd:\\programme\\python\\python39\\scripts\\'
Consider using the `--user` option or check the permissions.


<UserAccountName>@<DeviceName> D:\Programme\Python\Python39\Scripts
$ ..\python.exe -m pip install -U pip
D:\Programme\Python\Python39\python.exe: No module named pip

Code of Conduct

@Temmay Temmay added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Sep 25, 2021
@ziebam
Copy link
Contributor

ziebam commented Sep 25, 2021

I couldn't reproduce the issue (python is Python 3.9.7 at D:\Python397\python.exe), pip upgrades successfully.

C:\Users\[redacted]>python -m pip install -U pip
Requirement already satisfied: pip in d:\python397\lib\site-packages (21.2.3)
Collecting pip
  Using cached pip-21.2.4-py3-none-any.whl (1.6 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.2.3
    Uninstalling pip-21.2.3:
      Successfully uninstalled pip-21.2.3
Successfully installed pip-21.2.4

It seems like you had a file from D:\Programme\Python\Python39\Scripts open somewhere, or you lack write permissions in that directory. Please try to reproduce the issue after closing everything other than your ConEmu instance.

@uranusjr
Copy link
Member

Write permission is likely not the reason, because if the user lacks it pip shouldn't be able to remove itself either.

But I agree this is likely caused by something external and out of pip's control.

@pradyunsg pradyunsg added OS: windows Windows specific C: upgrade The logic of upgrading packages and removed S: needs triage Issues/PRs that need to be triaged labels Sep 26, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: upgrade The logic of upgrading packages OS: windows Windows specific type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants