100

For the past few weeks everytime I have downloaded a package using pip i get this: WARNING: Ignoring invalid distribution -ip (path to packages) . Any ideas why I get this?

5
  • 1
    This question was closed for being a duplicate. I disagree that it is a duplicate, but the question does require more clarity. Please include the version of Python and Pip you are using and list an example of the error, i.e. exactly what command you entered and the exact response. Gives an actual example of the error. Commented Aug 23, 2021 at 14:35
  • Does this answer your question? Pip "Ignoring invalid distribution" warning Commented Aug 23, 2021 at 16:20
  • @TomAranda First of all, this is a duplicate. And anyway, I don't see the benefit of opening it in its current state. As you said yourself, it lacks many details. It should have only been opened if and when the OP added the relevant details... Commented Aug 23, 2021 at 16:23
  • Does this answer your question? pip how to remove incorrectly installed package with a leading dash: "-pkgname" Commented Aug 23, 2021 at 16:44
  • 3
    I disagree with the "how do you dare to ask a question like that"-crows. I upvoted this question and the answer that helped me quickly solve my issue. Commented Sep 22, 2021 at 10:46

4 Answers 4

139

This occurs due to files names with the '~' prefix in site-packages. Please remove those files / folders. It will solve your problem.

You can list them with

ls -a /xx/xx/xx/lib/pythonx.x/site-packages | grep "^~"

Then remove files/folders prefixed by '~'.

Sign up to request clarification or add additional context in comments.

4 Comments

Did you really mean to have "not" in "It will not solve your problem"?
I do not have any such file/folders starting with a tilde... yet i get this error.... Any other suggestions around?
@DouglasJamesBock use the path from the warning message. the location is different if installed with --user
rm -r /home/$USER/.conda/envs/enivironment_name/lib/python3.x/site-packages/~*
61

go to 'site-packages' directory, delete folders whose name start with ~ (tilde)

Comments

3

I think this is your answer: pip renames itself to ~ip

...when pip updates or deletes a package, it renames the package name by replacing the first letter with a ‘ ~ ‘ or ’tilde,’ which is normal behavior. The problem here is that pip is renaming its own package (pip -> ~ip) without restoring it.

Whenever a pip update is executed, the default pip package is renamed to ~ip, and then a new pip package is installed following the removal of ~ip. So, if your update stops in between, it’ll leave the ~ip as it is...

When reviewing my case, this is what I found:

user@WINPC C:\Users\user\
$ python -m pip install --upgrade pip
Requirement already satisfied: pip in c:\python311\lib\site-packages (23.3.1)
Collecting pip
  Downloading pip-24.0-py3-none-any.whl.metadata (3.6 kB)
Downloading pip-24.0-py3-none-any.whl (2.1 MB)
   ---------------------------------------- 2.1/2.1 MB 1.7 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 23.3.1
    Uninstalling pip-23.3.1:
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'c:\\python311\\scripts\\pip.exe'
Consider using the `--user` option or check the permissions.

WARNING: Ignoring invalid distribution ~ip (C:\Python311\Lib\site-packages)

user@WINPC C:\Users\user\
$

So, it was left there because pip did not have permission to delete it during the upgrade process.

My solution was:

Administrator@WINPC C:\Python311\Lib\site-packages
# rmdir /s ~ip-23.3.1.dist-info
~ip-23.3.1.dist-info, Are you sure (Y/N)? y

Administrator@WINPC C:\Python311\Lib\site-packages
# rmdir /s ~ip
~ip, Are you sure (Y/N)? y

Administrator@WINPC C:\Python311\Lib\site-packages
#

Comments

0

Hi there I had this exact issue so what I did is that I right click python and went to file location, and then I went to the .exe file and right clicked it and went to file location, there I selected the Lib file and look for site packages, there were two files one that said ~pi and another one ~pi and some random numbers I erased the one that said ~pi and the random numbers and seemed to work for me.

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.