Skip to content

Instantly share code, notes, and snippets.

@kneerunjun
Last active July 2, 2016 10:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kneerunjun/185e473ae0f9951b314ae31906bfb78c to your computer and use it in GitHub Desktop.

Distributable python modules using distutils.core


If you have lately installed a module using python's distutils then you must have hit the wall when it comes to un-installing the same. python-pip is good but then it would not work if you have used python's distutils actually to install it in the first place.

This is most probably what you have done to install your python module

$ cd "module directory"
$ python3 setup.py sdist
$ sudo python3 setup.py install

#this is any one of the python shells.. 
> import <module name>
> 
# and it workS!!

But then you have no clue how to un-install it ?


python-pip is the intuitive next, but that does not work since it is deprecated and allpackages installed by distutils would have to be manually purged.

$ pip uninstall <packagename>
#does not remove.. 

# in the python shell
> import <packagename>

#still works!

Here is how you remove the module

$ sudo rm /usr/lib/python/site-packages/packagename*

# you are done

> import <packagename>
NameError : No such module found !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment