I have 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="[email protected]",
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 ?
Do I can do this with distutils ?
To use pip to uninstall a package locally in a virtual environment: Open a command or terminal window (depending on the operating system) cd into the project directory. pip uninstall <packagename>
The distutils package provides support for building and installing additional modules into a Python installation. The new modules may be either 100%-pure Python, or may be extension modules written in C, or may be collections of Python packages which include modules coded in both Python and C.
Navigate to Control Panel. Click “Uninstall a program”, and a list of all the currently installed programs will display. Select the Python version that you want to uninstall, then click the “Uninstall” button above the list – this has to be done for every Python version installed on the system.
Install the checkinstall Ubuntu package. checkinstall
monitors the installation procedure and creates a deb package. This lets you use regular package management commands to remove the software.
First, reinstall the candidate python module/package using checkinstall. Change directory to the directory containing the setup.py file of the candidate python module/package:
cd <PACKAGE_NAME>
Then:
sudo checkinstall -D --fstrans=no python setup.py install
This creates a .deb package, and installs the python module again. You'll be asked a few questions. The default answers should be fine. (But you might change the "name" of the .deb package, when the setup.py file is in a subdirectory of the python module, for example the "source" subdirectory.)
(The saved .deb package now captures how the python package installed itself, and dpkg can remove the python package.)
Then immediately remove the module:
sudo dpkg -r <PACKAGE_NAME>
PS. I've heard that some installation programs are not compatible with checkinstall
, though I've never run into any problems myself.
AFAIK only pip allows to uninstall python modules, so if you don't have it installed, you can install it with
sudo easy_install pip
and then use pip to uninstall your module
sudo pip uninstall <module_name>
where module_name
is the value passed in the name
argument of the setup
function.
Edit: just saw you tagged your question with "python-3.x", and there is no 3.x version for pip yet, so if you need to uninstall a python3.x module, this answer doesn't fit.
Since pip 8.0.0 running pip uninstall <package>
does not work when <package>
is something that was pre-installed by the OS (probably with python setup.py install).
The error message is:
Detected a distutils installed project ('
<package>
') which we cannot uninstall. The metadata provided by distutils does not contain a list of files which have been installed, so pip does not know which files to uninstall.
Instead of using pip to uninstall these packages you need to use the OS package manager instead.
So on Ubuntu: sudo apt-get remove python-<package>
would remove it.
I've found two packages that have this problem: httplib2 and six, and the above trick helped me get by that error. Hope that others find this useful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With