python setup.py uninstall python setup.py uninstall python python

python setup.py uninstall


Note: Avoid using python setup.py install use pip install .

You need to remove all files manually, and also undo any other stuff that installation did manually.

If you don't know the list of all files, you can reinstall it with the --record option, and take a look at the list this produces.

To record a list of installed files, you can use:

python setup.py install --record files.txt

Once you want to uninstall you can use xargs to do the removal:

xargs rm -rf < files.txt

Or if you're running Windows, use Powershell:

Get-Content files.txt | ForEach-Object {Remove-Item $_ -Recurse -Force}

Then delete also the containing directory, e.g. /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/my_module-0.1.egg/ on macOS. It has no files, but Python will still import an empty module:

>>> import my_module>>> my_module.__file__None

Once deleted, Python shows:

>>> import my_moduleTraceback (most recent call last):  File "<stdin>", line 1, in <module>ModuleNotFoundError: No module named 'my_module'


For me, the following mostly works:

have pip installed, e.g.:

$ easy_install pip

Check, how is your installed package named from pip point of view:

$ pip freeze

This shall list names of all packages, you have installed (and which were detected by pip).The name can be sometime long, then use just the name of the package being shown at the and after #egg=. You can also in most cases ignore the version part (whatever follows == or -).

Then uninstall the package:

$ pip uninstall package.name.you.have.found

If it asks for confirmation about removing the package, then you are lucky guy and it will be removed.

pip shall detect all packages, which were installed by pip. It shall also detect most of the packages installed via easy_install or setup.py, but this may in some rare cases fail.

Here is real sample from my local test with package named ttr.rdstmc on MS Windows.

$ pip freeze |grep ttrttr.aws.s3==0.1.1devttr.aws.utils.s3==0.3.0ttr.utcutils==0.1.1dev$ python setup.py develop..........Finished processing dependencies for ttr.rdstmc==0.0.1dev$ pip freeze |grep ttrttr.aws.s3==0.1.1devttr.aws.utils.s3==0.3.0-e hg+https://vlcinsky@bitbucket.org/vlcinsky/ttr.rdstmc@d61a9922920c508862602f7f39e496f7b99315f0#egg=ttr.rdstmc-devttr.utcutils==0.1.1dev$ pip uninstall ttr.rdstmcUninstalling ttr.rdstmc:  c:\python27\lib\site-packages\ttr.rdstmc.egg-linkProceed (y/n)? y  Successfully uninstalled ttr.rdstmc$ pip freeze |grep ttrttr.aws.s3==0.1.1devttr.aws.utils.s3==0.3.0ttr.utcutils==0.1.1dev

Edit 2015-05-20

All what is written above still applies, anyway, there are small modifications available now.

Install pip in python 2.7.9 and python 3.4

Recent python versions come with a package ensurepip allowing to install pip even when being offline:

$ python -m ensurepip --upgrade

On some systems (like Debian Jessie) this is not available (to prevent breaking system python installation).

Using grep or find

Examples above assume, you have grep installed. I had (at the time I had MS Windows on my machine) installed set of linux utilities (incl. grep). Alternatively, use native MS Windows find or simply ignore that filtering and find the name in a bit longer list of detected python packages.


The #1 answer has problems:

  • Won't work on mac.
  • If a file is installed which includes spaces or other specialcharacters, the xargs command will fail, and delete anyfiles/directories which matched the individual words.
  • the -r in rm -rf is unnecessary and at worst could delete things youdon't want to.

Instead, for unix-like:

sudo python setup.py install --record files.txt# inspect files.txt to make sure it looks ok. Then:tr '\n' '\0' < files.txt | xargs -0 sudo rm -f --

And for windows:

python setup.py bdist_wininstdist/foo-1.0.win32.exe

There are also unsolvable problems with uninstalling setup.py install which won't bother you in a typical case. For a more complete answer, see this wiki page:

https://ofswiki.org/wiki/Uninstalling_setup.py_install