How to uninstall a program installed with distutils?

I installed a python application with this setup.py:

#!/usr/bin/env python from distutils.core import setup from libyouandme import APP_NAME, APP_DESCRIPTION, APP_VERSION, APP_AUTHORS, APP_HOMEPAGE, APP_LICENSE setup( name=APP_NAME.replace(" ","-").lower(), version=APP_VERSION, description=APP_DESCRIPTION, author="John G", author_email=" xxx@gmail.com ", url=APP_HOMEPAGE, license=APP_LICENSE, scripts=["youandme.py"], packages=["libyouandme"], data_files=[ ('share/applications', ['youandme.desktop']), ('usr/share/icons/hicolor/16x16/apps', ['icons/hicolor/16x16/apps/you.png']), ('usr/share/icons/hicolor/22x22/apps', ['icons/hicolor/22x22/apps/you.png']), ('usr/share/icons/hicolor/48x48/apps', ['icons/hicolor/48x48/apps/you.png'])], ) 

How can I remove this application from my ubuntu machine?

Is it possible to do this with distutils?

+6
python ubuntu distutils
source share
4 answers

Install the checkinstall Ubuntu package. checkinstall monitors the installation procedure and creates a deb package. This allows you to use regular package management commands to remove software.

First reinstall the python candidate module / package using checkinstall. Change the directory to the directory containing the setup.py file from the python candidate module / package:

 cd <PACKAGE_NAME> 

Then:

 sudo checkinstall -D --fstrans=no python setup.py install 

This creates the .deb package and installs the python module again. You will be asked a few questions. The default answers must be accurate. (But you can change the "name" of the .deb package when the setup.py file is in a subdirectory of the python module, for example, a subdirectory of "source".)

(The saved .deb package now captures how the python package itself is installed, and dpkg can remove the python package.)

Then remove the module immediately:

 sudo dpkg -r <PACKAGE_NAME> 

PS. I heard that some setup programs are not compatible with checkinstall , although I have never encountered any problems myself.

+6
source share

AFAIK only pip allows you to remove python modules, so if you don't have one, you can install it with

 sudo easy_install pip 

and then use pip to remove your module.

 sudo pip uninstall <module_name> 

where module_name is the value passed in the name argument to the setup function.

Edit: just saw that you tagged your question with "python-3.x" and there is no 3.x version for pip yet, so if you need to remove the python3.x module, this answer is not suitable.

+5
source share

Disutils version 1 does not support the delete command, and I also included a link for you in the comment to see it, but for information only, disutils2 now supports the delete command, they worked on it in the past GSoC, you can check this link

The only way to “delete” your package is to delete all the files manually, I see that you have files in / usr / share .. I don’t know if you already know this, but you can use python install.py to develop your own module, it will easily change and delete.

+2
source share

Since pip 8.0.0 running pip uninstall <package> does not work when <package> is what the OS was pre-installed (possibly with python setup.py installed).

Error message:

A distutils installed project (' <package> ') was found that we cannot delete. The metadata provided by distutils does not contain a list of files that were installed, so pip does not know which files to delete.

Instead of using pip to remove these packages, you need to use the OS package manager instead.

So Ubuntu: sudo apt-get remove python-<package> will remove it.

I found two packages that have this problem: httplib2 and six , and the above trick helped me get this error. Hope others find this helpful.

0
source share

All Articles