python setup.py uninstall

python setup.py uninstall

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

n

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

n

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

n

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

n

python setup.py install --record files.txtn

n

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

n

xargs rm -rf < files.txtn

n

Or if youre running Windows, use Powershell:

n

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

n

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:

n

>>> import my_modulen>>> my_module.__file__nNonen

n

Once deleted, Python shows:

n

>>> import my_modulenTraceback (most recent call last):n  File <stdin>, line 1, in <module>nModuleNotFoundError: No module named my_modulen

For me, the following mostly works:

n

have pip installed, e.g.:

n

$ easy_install pipn

n

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

n

$ pip freezen

n

This shall list names of all packages, you have installed (and which were detected by pip).nThe 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 -).

n

Then uninstall the package:

n

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

n

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

n

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.

n

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

n

$ pip freeze |grep ttrnttr.aws.s3==0.1.1devnttr.aws.utils.s3==0.3.0nttr.utcutils==0.1.1devnn$ python setup.py developn.....n.....nFinished processing dependencies for ttr.rdstmc==0.0.1devnn$ pip freeze |grep ttrnttr.aws.s3==0.1.1devnttr.aws.utils.s3==0.3.0n-e hg+https://[email protected]/vlcinsky/[email protected]02f7f39e496f7b99315f0#egg=ttr.rdstmc-devnttr.utcutils==0.1.1devnn$ pip uninstall ttr.rdstmcnUninstalling ttr.rdstmc:n  c:\python27\lib\site-packages\ttr.rdstmc.egg-linknProceed (y/n)? yn  Successfully uninstalled ttr.rdstmcnn$ pip freeze |grep ttrnttr.aws.s3==0.1.1devnttr.aws.utils.s3==0.3.0nttr.utcutils==0.1.1devn

n

Edit 2015-05-20

n

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

n

Install pip in python 2.7.9 and python 3.4

n

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

n

$ python -m ensurepip –upgrade

n

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

n

Using grep or find

n

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.

python setup.py uninstall

The #1 answer has problems:

n

    n

  • Wont work on mac.
  • n

  • If a file is installed which includes spaces or other specialncharacters, the xargs command will fail, and delete anynfiles/directories which matched the individual words.
  • n

  • the -r in rm -rf is unnecessary and at worst could delete things youndont want to.
  • n

n

Instead, for unix-like:

n

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

n

And for windows:

n

python setup.py bdist_wininstndist/foo-1.0.win32.exen

n

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

n

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

Leave a Reply

Your email address will not be published.