-1

Earlier, my default Python version was python2.7.

To upgrade it, I deleted python from /usr/bin/ and renamed python3.6 as python in the same directory.

Afterwards, my terminal stopped working.

It gets no response on opening it.

  • Welcome to Ask Ubuntu! Which version of Ubuntu are you using? How did you delete /usr/bin/python and how did you rename /usr/bin/python3.6 as /usr/bin/python? – wjandrea Dec 02 '18 at 20:31
  • 1
    DO NOT rename python3.6 as python. Doing so will break your system quite horribly. Depending upon the version of Ubuntu you are using, it might be recoverable, it might not. – user535733 Dec 02 '18 at 20:33
  • ubuntu version-18.10, I deleted by going in the desired directory and simply by using the command rm command and rename it by mv python3.6 python – the unknown Dec 03 '18 at 18:53
  • Short Story: Python is integral to the system DO NOT remove Python nor edit the binaries, because Python and Python 3 operate differently, and are 'different software' – Thomas Ward Sep 09 '19 at 14:21

1 Answers1

4

The main lesson here is not to mess with system files unless you know exactly what you're doing. The directory /usr/bin is managed by the package manager, APT (as in apt-get and apt), so you will never need to manually make changes to it. You're not alone though. Lots of folks make changes to the system Python setup without realizing that most of the GUI depends on it.

Now, how can you fix this?

  1. Access a TTY. See What is a tty, and how do I access a tty?
  2. Put python3.6 back, cause the system depends on it (via /usr/bin/python3, which is a symlink to python3.6)

    sudo mv /usr/bin/python /usr/bin/python3.6
    
  3. Either reinstall python2.7

    sudo apt-get install --reinstall python2.7-minimal
    

    or remove it (warning OP is using Ubuntu 18.10, which does not rely on python-2.7 by default. If you're using a different version, don't do this)

    sudo apt-get remove python2.7
    
  4. Either figure out another way to set Python 3 as the default (see How to make 'python' program command execute Python 3?), or learn to live with typing python3 every time.
wjandrea
  • 14,236
  • 4
  • 48
  • 98