I am trying to install psutil with the command pip install -U psutil
and that gives me the error:
Cannot uninstall 'psutil'. 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.
It seems like this is a known issue in pip
with versions > 10
, and I understand that part (I currently have pip 18
). But I just found that I can solve it by directly doing a pip install psutil
without using the Upgrade
flag. I was wondering if there is a reasoning behind that. My initial sense is that in the first case, where pip
tries to upgrade, it first tries to remove the package, which it cannot, but in the latter case it tries to install directly, and hence does not get the error. My question is does it still not have to remove the package first and install (when not using the Upgrade flag), or why specifically is it that pip gives an error with an Upgrade flag but no error without it.
EDIT: So, I tried to run pip install -v psutil
as hoefling
suggested, and I got a whole bunch of text, as opposed to saying that requirements already met, which means that psutil didn't get installed in the first place. I tried to figure this a bit, and this is what I understand so far: I was running inside a python virtualenv
and installing it by means of pip -U -r requirements.txt
where requirements.txt
contains a bunch of packages including psutil
. When I remove the -U
flag, it skips installing psutil
, and jumps over to other packages. Which raises another question, whether this is how pip
is supposed to behave when there is no -U
flag. Its interesting that the first time, when its installing the packages with the -U flag, it looks inside the main python installation instead of the virtual environment one, and when the -U flag is removed it doesn't do that and skips entirely.