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

Ignoring invalid distribution -ip #10452

Closed
1 task done
baterflyrity opened this issue Sep 9, 2021 · 14 comments
Closed
1 task done

Ignoring invalid distribution -ip #10452

baterflyrity opened this issue Sep 9, 2021 · 14 comments
Labels
C: uninstall The logic for uninstallation of packages OS: windows Windows specific state: needs reproducer Need to reproduce issue type: bug A confirmed bug or unintended behavior

Comments

@baterflyrity
Copy link

Description

After installing pip via get-pip.py I obtain mystic packages starting from ~ in site packages directory.

Expected behavior

Installing pip on clear python without pip must not flood warnings and create error packages.

pip version

Python version

3.9

OS

Windows 10

How to Reproduce

Reproducing

user@host MINGW64 ~                                                                                 
$ pip list | grep pip                                                                                           
Traceback (most recent call last):                                                                              
  File "C:\Python39\lib\runpy.py", line 197, in _run_module_as_main                                             
    return _run_code(code, main_globals, None,                                                                  
  File "C:\Python39\lib\runpy.py", line 87, in _run_code                                                        
    exec(code, run_globals)                                                                                     
  File "C:\Python39\Scripts\pip.exe\__main__.py", line 4, in <module>                                           
ModuleNotFoundError: No module named 'pip'   

user@host MINGW64 ~                                                                                  
$ curl https://bootstrap.pypa.io/get-pip.py > get-pip.py                                             
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                                 
                                 Dload  Upload   Total   Spent    Left  Speed                                   
100 1911k  100 1911k    0     0  2359k      0 --:--:-- --:--:-- --:--:-- 2362k                                  
                                                                                                                
user@host MINGW64 ~                                             
$ sudo py ./get-pip.py                                                     
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) 
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) 
Collecting pip                                                             
  Using cached pip-21.2.4-py3-none-any.whl (1.6 MB)                        
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) 
Installing collected packages: pip                                         
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) 
Successfully installed pip-21.2.4                                          
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) 
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) 
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) 
                                                                           
user@host MINGW64 ~                                             
$ pip list | grep pip                                                      
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) 
pip                       21.2.4                                           
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages) 
WARNING: Ignoring invalid distribution -ip (c:\python39\lib\site-packages)        

user@host MINGW64 ~
$ ls c:\\python39\\lib\\site-packages | grep ~ip
~ip/
~ip-21.2.3.dist-info/                                                         

Temporary solution

user@host MINGW64 ~
$ rm -rf /c//python39//lib//site-packages/~ip*

user@host MINGW64 ~
$ pip list | grep pip
pip                       21.2.4

user@host MINGW64 ~
$ ls c:\\python39\\lib\\site-packages | grep ~ip

p.s.
sudo is as temporary solution to #9527

Output

No response

Code of Conduct

@baterflyrity baterflyrity added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Sep 9, 2021
@DiddiLeija
Copy link
Member

When pip updates or deletes a package, it renames the package name by replacing the first letter with a ~. I think this a normal behavior.

The problem here is that pip is renaming its own package (pip -> ~ip) without restoring it.

@baterflyrity
Copy link
Author

baterflyrity commented Sep 10, 2021

When pip updates or deletes a package, it renames the package name by replacing the first letter with a ~. I think this a normal behavior.

The problem here is that pip is renaming its own package (pip -> ~ip) without restoring it.

It happens during installation of pip but updating or deletation.

@uranusjr
Copy link
Member

There are a myriad of things can happen on Windows that make file deletion fail. We should add a message in the warning message to tell the user to delete those files manually.

@arpost
Copy link

arpost commented Dec 1, 2021

I see this with many packages on Windows 10 when I use the --force-reinstall option, which appears to be broken on Windows 10. One of the packages I see this with is cffi. It looks like a filename parsing bug because pip keeps generating new files in my site packages directory starting with -ffi, -fi, etc.

@pradyunsg
Copy link
Member

Does anyone have a repeatable approach for generating such invalid distributions?

@pradyunsg pradyunsg added OS: windows Windows specific S: awaiting response Waiting for a response/more information C: uninstall The logic for uninstallation of packages state: needs reproducer Need to reproduce issue and removed S: needs triage Issues/PRs that need to be triaged labels Mar 11, 2022
@uranusjr
Copy link
Member

Try to hard-crash pip during an uninstallation (something like os._exit(1) that does not allow auto restore to happen), after pip renames the old installation but before actually deleting it.

@baterflyrity
Copy link
Author

baterflyrity commented Mar 11, 2022

Try to hard-crash pip during an uninstallation (something like os._exit(1) that does not allow auto restore to happen), after pip renames the old installation but before actually deleting it.

No)) This issue happens during regular installation process.

@no-response no-response bot removed the S: awaiting response Waiting for a response/more information label Mar 11, 2022
@uranusjr
Copy link
Member

I was answering the question what is a repeatable approach to trigger this. It may not match your experience on hitting the bug, but is the most realiable way to reproduce the phenomenom.

@baterflyrity
Copy link
Author

baterflyrity commented Mar 11, 2022

@uranusjr , actually one can just create necessary folders. But i cant consider this as "reproducable approach".

@snoopyjc
Copy link

snoopyjc commented Jan 3, 2023

This just happened to me. The requirements_dev.txt I tried installing had an old version of pip listed in it as a requirement and the installed failed as it couldn't remove the running pip command but left me in a state that a pip command would no longer work, then once I followed some repair steps, I started getting tons of warnings and found ~ip and ~ip-21.2.4.dist-info folders in my site-packages.

@DiddiLeija
Copy link
Member

DiddiLeija commented Jan 3, 2023

@snoopyjc, a quick way to fix this issue is to manually remove those folders. They are harmless.

@uranusjr
Copy link
Member

uranusjr commented Jan 3, 2023

Also if I remember correctly recent pip versions would no longer complain about this (and would simply leave those trash folders there, for better or for worse). So I’ll close this.

@uranusjr uranusjr closed this as completed Jan 3, 2023
@snoopyjc
Copy link

snoopyjc commented Jan 3, 2023

@snoopyjc, a quik way to fix this issue is to manually remove those folders. They are harmless.

Yes that’s what I did - thanks!!

@baterflyrity
Copy link
Author

Also if I remember correctly recent pip versions would no longer complain about this (and would simply leave those trash folders there, for better or for worse). So I’ll close this.

Ignoring a problem does not solve the problem.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: uninstall The logic for uninstallation of packages OS: windows Windows specific state: needs reproducer Need to reproduce issue type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

6 participants