How do I remove packages installed with Python’s easy_install?

Python Programming

Question or problem about Python programming:

Python’s easy_install makes installing new packages extremely convenient. However, as far as I can tell, it doesn’t implement the other common features of a dependency manager – listing and removing installed packages.

What is the best way of finding out what’s installed, and what is the preferred way of removing installed packages? Are there any files that need to be updated if I remove packages manually (e.g. by rm /usr/local/lib/python2.6/dist-packages/my_installed_pkg.egg or similar)?

How to solve the problem:

Solution 1:

pip, an alternative to setuptools/easy_install, provides an “uninstall” command.

Install pip according to the installation instructions:

$ wget
$ python

Then you can use pip uninstall to remove packages installed with easy_install

Solution 2:

To uninstall an .egg you need to rm -rf the egg (it might be a directory) and remove the matching line from site-packages/easy-install.pth

Solution 3:

First you have to run this command:

$ easy_install -m [PACKAGE]

It removes all dependencies of the package.

Then remove egg file of that package:

$ sudo rm -rf /usr/local/lib/python2.X/site-packages/[PACKAGE].egg

Solution 4:

All the info is in the other answers, but none summarizes both your requests or seem to make things needlessly complex:

  • For your removal needs use:

    pip uninstall <package> 

    (install using easy_install pip)

  • For your ‘list installed packages’ needs either use:

    pip freeze 


    yolk -l 

    which can output more package details.

    (Install via easy_install yolk or pip install yolk)

Solution 5:

There are several sources on the net suggesting a hack by reinstalling the package with the -m option and then just removing the .egg file in lib/ and the binaries in bin/. Also, discussion about this setuptools issue can be found on the python bug tracker as setuptools issue 21.

Edit: Added the link to the python bugtracker.

Hope this helps!