python setup.py uninstall


Python's distutils mechanism makes distributing and installing modules simple.

In most cases, either

python setup.py build
python setup.py install

or just

python setup.py install

is all that's necessary.

Unfortunately (and somewhat surprisingly), there's no uninstall option specified.

Manually deleting the .egg-info file and corresponding folder from the python site-packages folder is one way, but if the installer used an alternative or custom setup, then there is no way to be sure all the associated files and dependencies are gone.

The way around this is to use the --record switch with setup.py at install, which will log all the files corresponding to the module:

python setup.py install --record files.txt

Then, to uninstall (either ahead of a version upgrade or outright deletion), just use the contents of files.txt to guide the removal:

cat files.txt | xargs rm -rf

Hat tip to Michal Čihař, via StackOverFlow.