1

I am installing the following python module

pip install ipaddress-1.0.23-py2.py3-none-any.whl

the pip failed on

Processing ipaddress-1.0.23-py2.py3-none-any.whl
Installing collected packages: ipaddress
  Attempting uninstall: ipaddress
    Found existing installation: ipaddress 1.0.16
ERROR: Cannot uninstall 'ipaddress'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

What isn’t clear here why pip trying to uninstall the current pkg - ipaddress 1.0.16

As all can see we not using the option --force-reinstall

So why pip install is removing the current - ipaddress 1.0.16 ?

Reference - Difference between pip install options "ignore-installed" and "force-reinstall"

jessica
  • 2,426
  • 24
  • 66
  • What `pip` version do you use? – hoefling Jun 22 '20 at 17:25
  • 21 version , after upgrade from 8 – jessica Jun 22 '20 at 17:26
  • 1
    You are installing from a wheel file directly, this is effectively the same as saying `pip install ipaddress==1.0.23`. The currently installed version of `ipaddress` doesn't match this requirement, so `pip` tries to uninstall that, giving you the famous error of being unable to uninstall an "old and unmanageable" package. You can either loosen the requirement by issuing `pip install ipaddress --find-links=.` (assuming `.` contains the wheel file), this will install nothing. Or downgrade `pip` to 9.0, uninstall `ipaddress` and reinstall the new version from wheel. – hoefling Jun 22 '20 at 17:38
  • now , i used the option - --ignore-installed , and its installed successfully , do you have any remarks about this? – jessica Jun 22 '20 at 17:56
  • The same thoughts as in the linked answer - `--ignore-installed` doesn't uninstall, only overwrite files. Depending on how `ipaddress` was installed before, you may still have remainings of 1.0.16 lying around in the site. Try `pip uninstall -y ipaddress` and then `pip show ipaddress`, what do you get? – hoefling Jun 22 '20 at 18:04
  • sorry for delay , I not near the machine , so I will update , just want to know if you think that option - --ignore-installed is good enough ? – jessica Jun 22 '20 at 20:57
  • No, it's not good enough. – hoefling Jun 23 '20 at 13:51

2 Answers2

1

It's because you cannot have multiple versions of a single package name installed at one time.

The way that Python packaging is set up, an installation directory should only contain a single version for each package name. In this case, the wheel that you're trying to install conflicts with another package; which means that pip will attempt to install over that package.

Outside of hacky things like --ignore-installed which can overwrite files and leave you in a completely borked installation directory, there isn't really any way to avoid performing such an uninstall at the time of writing.

IMO, you likely should isolate from the existing installation by using a virtual environment. My guess is that the distutils-based installation is actually one that was installed by your OS package manager and you don't wanna be meddling with those files using pip.

pradyunsg
  • 18,287
  • 11
  • 43
  • 96
0

Try to run:

sudo pip install ipaddress==1.0.23 --ignore-installed
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Angellaugh
  • 17
  • 4
  • 1
    Hmm... this is a bad idea for a couple of major reasons -- 1. Don't run sudo pip (https://stackoverflow.com/a/22517157/1931274), 2. Using `--ignore-installed` is a sure-fire way to end up with a broken installation directory. – pradyunsg Apr 06 '23 at 17:58