5

On OS X 10.6.8, I uninstalled a package using (at least pip tells me so)

sudo pip uninstall pkg_name

but the package still shows up when I do

pip freeze

I try to do the uninstall command above again, and pip tells me the package is not installed.

What is the problem here? How do I verify whether the package is uninstalled or not? If so, can I refresh some sort of index of pip to get it corrected?

MLister
  • 10,022
  • 18
  • 64
  • 92

3 Answers3

4

I thought you may have two pip binaries, and when you run as sudo, your shell chooses the wrong one, at first. But it does not make any sense if you run it again as sudo and pip removed the package. Did you do exactly this?

If you did not run the same commands twice, you may have different pip binaries running the uninstall and freeze. Check if the following two commands result in the same output:

$ sudo pip freeze
# ... sudo output
$ pip freeze
# ... normal output

Anyway, you can check if the package is installed using:

$ python -c 'import pkg_name' &> /dev/null && echo installed || echo not installed

There is no sort of refresh feature in pip.

Hugo Lopes Tavares
  • 28,528
  • 5
  • 47
  • 45
  • I ran the `pip freeze` with `sudo` and without, and the results are indeed different, three packages extra without `sudo`. Also, the output of `yolk -l` shows that I have two versions of `pip` installed with the older version marked as **inactive**, is this related to the different outputs from `pip freeze`? If so, how should I correct this situation? Thanks! – MLister Jul 26 '12 at 15:39
  • It is not related to the `pip freeze` output as I know. You are just using two different `pip` binaries. You can use absolute paths to desambiguate: /path/to/bin/pip freeze. Use `which pip` and `sudo which pip` to find where your `pip`s are located. – Hugo Lopes Tavares Jul 30 '12 at 23:26
4

I had this same problem and it was due to broken symlinks from homebrew once the file was uninstalled.

$ pip freeze | grep Magic
Magic-file-extensions==0.2

$ pip uninstall Magic-file-extensions
# say `y` at prompt / see it go through as success

$ pip freeze | grep Magic # still there :(
Magic-file-extensions==0.2

$ ll /usr/local/lib/python2.7/site-packages/ | grep Magic # symlink shows up red
├── [lrwxr-xr-x tomfuert   98 Feb 16 11:06]  Magic_file_extensions-0.2-py2.7.egg-info -> ../../../Cellar/libmagic/5.17/lib/python2.7/site-packages/Magic_file_extensions-0.2-py2.7.egg-info

$ rm /usr/local/lib/python2.7/site-packages/Magic_file_extensions-0.2-py2.7.egg-info

$ pip freeze | grep Magic
# nothing!
TomFuertes
  • 7,150
  • 5
  • 35
  • 49
1

If you use a virtual environment, try clean command. Don't forget sudo.

sudo pipenv clean
cegprakash
  • 2,937
  • 33
  • 60