HiveBrain v1.2.0
Get Started
← Back to all entries
patternpythonCritical

Python setup.py uninstall

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
setupuninstallpython

Problem

I have installed a Python package with python setup.py install.

How do I uninstall it?

Solution

Note: Avoid using python setup.py install. Instead, 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

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 doesn't have any files, but Python will still import an empty module:
>>> import my_module
>>> my_module.__file__
None


Once deleted, Python shows:
>>> import my_module
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'my_module'
`

Context

Stack Overflow Q#1550226, score: 1161

Revisions (0)

No revisions yet.