patternpythonCriticalCanonical
Python setup.py uninstall
Viewed 0 times
pythonuninstallsetup
Problem
I have installed a Python package with
How do I uninstall it?
python setup.py install.How do I uninstall it?
Solution
Note: Avoid using
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
To record a list of installed files, you can use:
Once you want to uninstall you can use xargs to do the removal:
>>> my_module.__file__
None
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'my_module'
`
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_moduleTraceback (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.