How do you uninstall a python package that was installed using distutils?

Solution 1:

It varies based on the options that you pass to install and the contents of the distutils configuration files on the system/in the package. I don't believe that any files are modified outside of directories specified in these ways.

Notably, distutils does not have an uninstall command at this time.

It's also noteworthy that deleting a package/egg can cause dependency issues – utilities like easy_install attempt to alleviate such problems.

Solution 2:

The three things that get installed that you will need to delete are:

  1. Packages/modules
  2. Scripts
  3. Data files

Now on my linux system these live in:

  1. /usr/lib/python2.5/site-packages
  2. /usr/bin
  3. /usr/share

But on a windows system they are more likely to be entirely within the Python distribution directory. I have no idea about OSX except it is more likey to follow the linux pattern.

Solution 3:

Another time stamp based hack:

  1. Create an anchor: touch /tmp/ts
  2. Reinstall the package to be removed: python setup.py install --prefix=<PREFIX>
  3. Remove files what are more recent than the anchor file: find <PREFIX> -cnewer /tmp/ts | xargs rm -r