Computer >> Computer tutorials >  >> Programming >> Python

How to delete an installed module in Python?


You can uninstall most installed Python packages using pip. For more info on pip uninstall, head over to: https://pip.pypa.io/en/stable/reference/pip_uninstall/. For example, if you have numpy package installed and want to uninstall it, then enter the following:

$ pip uninstall numpy

However there are some exceptions. These packages cant be removed easily using pip:

1. Pure distutils packages installed with python setup.py install, which leave behind no metadata to determine what files were installed.

2. Script wrappers installed by python setup.py develop.

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 list of installed files, you can use:

$ python setup.py install --record files.txt

Now you'll have a list of all files in the files.txt, which you can then manually remove.