views:

7951

answers:

6

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)?

+10  A: 

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.

Chris089
Thanks for this info. For other's reference, here's the link to the issue that you mentioned: http://bugs.python.org/setuptools/issue21
ire_and_curses
+9  A: 

If the problem is a serious-enough annoyance to you, you might consider virtualenv. It allows you to create an environment that encapsulates python libraries. You install packages there rather than in the global site-packages directory. Any scripts you run in that environment have access to those packages (and optionally, your global ones as well). I use this a lot when evaluating packages that I am not sure I want/need to install globally. If you decide you don't need the package, it's easy enough to just blow that virtual environment away. It's pretty easy to use. Make a new env:

$>virtualenv /path/to/your/new/ENV

virtual_envt installs setuptools for you in the new environment, so you can do:

$>ENV/bin/easy_install

You can even create your own boostrap scripts that setup your new environment. So, with one command, you can create a new virtual env with, say, python 2.6, psycopg2 and django installed by default (you can can install an env-specific version of python if you want).

mazelife
+10  A: 

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

joeforker
+3  A: 

try

$ easy_install -m [PACKAGE]

then

$ rm -rf .../python2.X/site-packages/[PACKAGE].egg
Jim Geovedi
+2  A: 

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

lunaryorn
Hey it actually does! Thanks! I was annoyed at one point that it didn't. For some reason my system was stuck at version 0.3.1 of `pip`; I had to feed `easy_install` the URL to the tarball for version 0.8.1 in order to update to a version that has the `uninstall` command.
intuited
+2  A: 

Official(?) instructions: http://peak.telecommunity.com/DevCenter/EasyInstall#uninstalling-packages

Mark