Cannot uninstall python on Ubuntu?

5,913

Solution 1

This seems like an XY-problem. Problem Y, uninstalling Python 3, will break your OS. Don't do that.

Problem X is not clear, but assuming it's that the system Python 3 executable is damaged, you can reinstall it via the package python3.5-minimal:

sudo apt-get install --reinstall python3.5-minimal

Solution 2

Ubuntu 16.04 comes with Python3 installed by default. If you want to install Python 2 you can run:

sudo apt install python-minimal

On the command line you should use python3 or python2 to execute scripts.

Also take note that ubuntu-desktop is a package that will install a full display system such as X server and Gnome packages, none of which you'll have much use for if connecting over SSH.

However, the problem you may have now is that you've attempted (or succeeded to some degree) in removing Python, which is actually what the package management tool apt uses to install/remove packages.

Share:
5,913

Related videos on Youtube

katro coplax
Author by

katro coplax

Updated on September 18, 2022

Comments

  • katro coplax
    katro coplax over 1 year

    I have confused to uninstall python3 or fix my VPS Ubuntu

    Im using Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-31-generic x86_64)

    I tried to uninstall all python packages

    sudo apt-get purge python3

    And getting this error

    dpkg: error processing package python3-pkg-resources (--remove):
     subprocess installed pre-removal script returned error exit status 127                               Processing triggers for libc-bin (2.23-0ubuntu10) ...
    Errors were encountered while processing:
     python3-lxml
     python3-pip
     python3-apt
     python3-pyparsing
     gir1.2-ibus-1.0:amd64
     hplip-data
     python3-blinker
     python3-bs4
     python3-cairo
     python3-chardet
     python3-dbus
     python3-defer
     python3-feedparser
     python3-gi
     python3-guacamole
     python3-httplib2
     python3-idna
     python3-jwt
     python3-louis
     python3-markupsafe
     python3-padme
     python3-setuptools
     python3-problem-report
     python3-ptyprocess
     python3-pyasn1
     python3-pycurl
     python3-six
     python3-wheel
     python3-xdg
     python3-xkit
     python3-xlsxwriter
     dh-python
     python3
     python3-pkg-resources
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    

    I tried other way from other site,error still same And i tried to reinstall my ubuntu with command line

    apt-get install --reinstall ubuntu-desktop

    I dont know should i do to fix my ubuntu and reinstall my python.

    Note: I tried to run python3 it not working with reasons python3 is not package and i run python3.7 it working fine,idk python3.7 thats reall python package i have or something else :/

    Im so appreciate any help

    • katro coplax
      katro coplax over 5 years
      Im just want to uninstall and reinstall it,bcz before what i do that i have some error,
    • j-money
      j-money over 5 years
      Don't this is a terrible idea, python3 is a dependency for so much (I think even apt is a dependency) edit: Gah someone beat me to it
    • Thomas Ward
      Thomas Ward over 5 years
      Removing Python 3 will destroy the operational state of your system because so many things depend on it. DO NOT remove Python 3 from your system. Instead, address the actual errors you're seeing, rather than assume that Python 3 being present is the cause.
  • wjandrea
    wjandrea over 5 years
    Doesn't 16.04 come with Python 2 installed? I thought 17.10 was the first release not to.
  • Kristopher Ives
    Kristopher Ives over 5 years
    I thought so too, but I actually fired up 16.04.5 in a VM and it's not there by default at least with a server installation, only python3 was.
  • Kristopher Ives
    Kristopher Ives over 5 years
    If you've "successfully" removed python3 you cannot actually run most apt commands.
  • wjandrea
    wjandrea over 5 years
    @Kristopher Good point. I assume the output in the question indicates that no action was taken, but I might be wrong.
  • Adam Beleko
    Adam Beleko over 2 years
    I accidentally uninstalled python3 on ubuntu 20.04. The system wouldn't boot successfully, giving "/dev/sda2: clean ****/**** files ****/**** blocks". Installing python3-minimal and ubuntu-desktop saved me from unemployment. LOL