pip icon indicating copy to clipboard operation
pip copied to clipboard

Uninstalling editable install in the same directory is interfered by the generated egg-info folder

Open fireattack opened this issue 6 months ago • 8 comments

Description

When installing a module via pip install -e ., it will generate a {module_name}.egg-info folder in the same folder. This causes issue when you later want to uninstall the said module via pip uninstall module_name, because it will prioritize the .egg-info in the current folder instead of the one in global.

It will also has similar issues when trying to re-rum pip install -e . (something about "unable to uninstall ..").

One has to manually delete that {module_name}.egg-info folder, or use a different working directory, to be able to uninstall the installed module properly.

Below is a log to show that.

Expected behavior

Expected: pip_bug can be uninstalled globally Observed: pip_bug cannot be uninstalled in CWD unless manually removing the egg-info folder.

pip version

25.1.1

Python version

3.13

OS

Windows 10

How to Reproduce

  1. Clone https://github.com/fireattack/pip_bug and cd into it.
  2. pip install -e .
  3. pip uninstall pip_bug

Output

(py313) D:\temp\!bugs\pip_bug>pip install -e .
Obtaining file:///D:/temp/%21bugs/pip_bug
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: pip_bug
  Building editable for pip_bug (pyproject.toml) ... done
  Created wheel for pip_bug: filename=pip_bug-0.1.0-0.editable-py3-none-any.whl size=4356 sha256=a0c24a23ce7a49052a8f62cb6f9a270bb2444133b0994d853e8563b2a167ad06
  Stored in directory: C:\Users\ikena\AppData\Local\Temp\pip-ephem-wheel-cache-b6k23gkq\wheels\9a\ad\9b\67d33404ac56ce92b46c9ea550bb2bca23750c1e241146bf37
Successfully built pip_bug
Installing collected packages: pip_bug
Successfully installed pip_bug-0.1.0

(py313) D:\temp\!bugs\pip_bug>pip uninstall pip_bug
Found existing installation: pip_bug 0.1.0
Can't uninstall 'pip_bug'. No files were found to uninstall.

(py313) D:\temp\!bugs\pip_bug>rmdir pip_bug.egg-info /s /q

(py313) D:\temp\!bugs\pip_bug>pip uninstall pip_bug
Found existing installation: pip_bug 0.1.0
Uninstalling pip_bug-0.1.0:
  Would remove:
    c:\users\ikena\anaconda3\envs\py313\lib\site-packages\__editable__.pip_bug-0.1.0.pth
    c:\users\ikena\anaconda3\envs\py313\lib\site-packages\__editable___pip_bug_0_1_0_finder.py
    c:\users\ikena\anaconda3\envs\py313\lib\site-packages\pip_bug-0.1.0.dist-info\*
Proceed (Y/n)? y
  Successfully uninstalled pip_bug-0.1.0

Code of Conduct

fireattack avatar Jul 02 '25 02:07 fireattack

I cannot reproduce this bug on Linux, though:

vpsadmin@vultr:~/pip_bug$ pip install -e .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/vpsadmin/pip_bug
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: pip_bug
  Building editable for pip_bug (pyproject.toml) ... done
  Created wheel for pip_bug: filename=pip_bug-0.1.0-0.editable-py3-none-any.whl size=4329 sha256=7e4b05fc19bb029ec3f52808df2b742cbd348995911c8c64744f43bd022fc3ef
  Stored in directory: /tmp/pip-ephem-wheel-cache-sxqq_3f_/wheels/2b/ed/c0/3c62a2af01e016a44e90a36931ce4b9aebed634f347f9b172e
Successfully built pip_bug
Installing collected packages: pip_bug
Successfully installed pip_bug-0.1.0

[notice] A new release of pip is available: 25.0.1 -> 25.1.1
[notice] To update, run: python3.11 -m pip install --upgrade pip
vpsadmin@vultr:~/pip_bug$ pip uninstall pip_bug
Found existing installation: pip_bug 0.1.0
Uninstalling pip_bug-0.1.0:
  Would remove:
    /home/vpsadmin/.local/lib/python3.11/site-packages/__editable__.pip_bug-0.1.0.pth
    /home/vpsadmin/.local/lib/python3.11/site-packages/__editable___pip_bug_0_1_0_finder.py
    /home/vpsadmin/.local/lib/python3.11/site-packages/pip_bug-0.1.0.dist-info/*
Proceed (Y/n)? y
  Successfully uninstalled pip_bug-0.1.0

fireattack avatar Jul 02 '25 03:07 fireattack

Thanks for the detailed report and reproducer. Be aware it may take some time for a mainter to take a detailed look as, at the moment, we're all supporting pip in our spare time.

One quick question, do you know if this happens with different backends like flit or hatchling?

notatallshaw avatar Jul 02 '25 03:07 notatallshaw

Thanks for the detailed report and reproducer. Be aware it may take some time for a mainter to take a detailed look as, at the moment, we're all supporting pip in our spare time.

One quick question, do you know if this happens with different backends like flit or hatchling?

Changing build-backend to hatchling.build or flit_core.buildapi will not trigger this bug as they don't create an .egg-info folder in the root directory.

fireattack avatar Jul 02 '25 04:07 fireattack

Hi @fireattack, I tried to reproduce this on Windows 10 with Python 3.13 and pip 25.1.1 (using setuptools in a venv), but uninstalling worked correctly for me even with .egg-info present.

Could you confirm if this still happens on the latest pip, and let us know more about your environment? That might help narrow it down.

sepehr-rs avatar Sep 29 '25 16:09 sepehr-rs

yes this still happens with latest pip 25.2:

(py313) D:\pip_bug>python -m pip install pip -U
Requirement already satisfied: pip in c:\users\ikena\anaconda3\envs\py313\lib\site-packages (25.0)
Collecting pip
  Downloading pip-25.2-py3-none-any.whl.metadata (4.7 kB)
Downloading pip-25.2-py3-none-any.whl (1.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 69.4 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 25.0
    Uninstalling pip-25.0:
      Successfully uninstalled pip-25.0
Successfully installed pip-25.2

(py313) D:\pip_bug>pip install -e .
Obtaining file:///D:/pip_bug
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: pip_bug
  Building editable for pip_bug (pyproject.toml) ... done
  Created wheel for pip_bug: filename=pip_bug-0.1.0-0.editable-py3-none-any.whl size=4347 sha256=c8dbfc9e57c859dc55a6211fa16a8ae259abff88528958b55750bdf77d299884
  Stored in directory: C:\Users\ikena\AppData\Local\Temp\pip-ephem-wheel-cache-c41bhxfn\wheels\19\09\b4\6413416b14776637d6ae05349ba530f051615547aad8ec2fee
Successfully built pip_bug
Installing collected packages: pip_bug
Successfully installed pip_bug-0.1.0

(py313) D:\pip_bug>pip uninstall pip_bug
Found existing installation: pip_bug 0.1.0
Can't uninstall 'pip_bug'. No files were found to uninstall.

(py313) D:\pip_bug>

My env:

Windows 10 Python 3.13.5, installed in clean conda env (but I can reproduce this with my global native python 3.11 too)

>pip list
Package            Version
------------------ ---------
certifi            2025.4.26
charset-normalizer 3.4.1
colorama           0.4.6
idna               3.10
markdown-it-py     3.0.0
mdurl              0.1.2
pip                25.2
pip_bug            0.1.0
Pygments           2.19.1
requests           2.32.3
rich               14.0.0
setuptools         75.8.0
tqdm               4.67.1
urllib3            2.4.0
wheel              0.45.1

let me know what else do you need

fireattack avatar Sep 29 '25 16:09 fireattack

D:\pip_bug>python -m venv .v

D:\pip_bug>.v\Scripts\activate.bat

(.v) D:\pip_bug>python -m pip install pip -U
Requirement already satisfied: pip in d:\pip_bug\.v\lib\site-packages (22.3.1)
Collecting pip
  Downloading pip-25.2-py3-none-any.whl (1.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 108.9 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.3.1
    Uninstalling pip-22.3.1:
      Successfully uninstalled pip-22.3.1
Successfully installed pip-25.2

(.v) D:\pip_bug>pip install -e .
Obtaining file:///D:/pip_bug
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: pip_bug
  Building editable for pip_bug (pyproject.toml) ... done
  Created wheel for pip_bug: filename=pip_bug-0.1.0-0.editable-py3-none-any.whl size=4347 sha256=2710d6fee7d5bfe7bad5b9559fcc46951eb17dbc07df7079f4a4f028a14d08de
  Stored in directory: C:\Users\ikena\AppData\Local\Temp\pip-ephem-wheel-cache-vl2f__bu\wheels\a2\c3\7c\a8dd4c9bec736714699472a8aaf4c7e5dc7a6af4af1e47f2a1
Successfully built pip_bug
Installing collected packages: pip_bug
Successfully installed pip_bug-0.1.0

(.v) D:\pip_bug>pip uninstall pip_bug
Found existing installation: pip_bug 0.1.0
Not uninstalling pip-bug at d:\pip_bug, outside environment D:\pip_bug\.v
Can't uninstall 'pip_bug'. No files were found to uninstall.

(.v) D:\pip_bug>python --version
Python 3.11.1

(.v) D:\pip_bug>

Can also reproduce in a venv virtual env (albeit 3.11).

fireattack avatar Sep 29 '25 16:09 fireattack

Thanks for the detailed logs, @fireattack! I still can't reproduce this, unfortunately:

PS C:\Users\sepehr\pip_bug> python -m venv venv

PS C:\Users\sepehr\pip_bug> .\venv\Scripts\Activate.ps1

(venv) PS C:\Users\sepehr\pip_bug> pip install -e .
Obtaining file:///C:/Users/sepehr/pip_bug
Installing build dependencies ... done
Checking if build backend supports build_editable ... done
Getting requirements to build editable ... done
Preparing editable metadata (pyproject.toml) ... done

Building wheels for collected packages: pip_bug
  Building editable for pip_bug (pyproject.toml) ... done
  Created wheel for pip_bug: 
    filename=pip_bug-0.1.0-0.editable-py3-none-any.whl 
    size=4363 
    sha256=3fafc13257fee7bccf357b0ac9180afea2963e4d1b996f3206cbbc438df088be
  Stored in directory: 
    C:\Users\sepehr\AppData\Local\Temp\pip-ephem-wheel-cache-0hk33634\wheels\25\d3\90\14028bda1ecc88f1f2c8d26b69d22c096a45cef3fa37e7ab98

Successfully built pip_bug
Installing collected packages: pip_bug
Successfully installed pip_bug-0.1.0

[notice] A new release of pip is available: 25.1.1 -> 25.2
[notice] To update, run: python.exe -m pip install --upgrade pip

(venv) PS C:\Users\sepehr\pip_bug> pip uninstall pip_bug
Found existing installation: pip_bug 0.1.0
Uninstalling pip_bug-0.1.0:
  Would remove:
    c:\users\sepehr\pip_bug\venv\lib\site-packages\__editable__.pip_bug-0.1.0.pth
    c:\users\sepehr\pip_bug\venv\lib\site-packages\__editable___pip_bug_0_1_0_finder.py
    c:\users\sepehr\pip_bug\venv\lib\site-packages\pip_bug-0.1.0.dist-info\*

Proceed (Y/n)? y
Successfully uninstalled pip_bug-0.1.0

Looping in @pfmoore, since he has much more experience with pip on Windows. @pfmoore, I tried reproducing this bug exactly as @fireattack described, but wasn’t able to. I know you’re busy, and I don’t want to add to your workload, just flagging it in case you get a chance to look.

sepehr-rs avatar Sep 29 '25 17:09 sepehr-rs

It would be interesting to see if this is still reproducible with #13602.

sbidoul avatar Sep 29 '25 18:09 sbidoul