Ubuntu – Problem with python in Ubuntu 18.10


I recently upgraded to 18.10 from 18.04, but I am facing a new problem.

When I type python, I am getting this

Python 3.7.3 (default, Apr 9 2019, 04:56:51)

[GCC 8.3.0] on linux

But when I type python3, I am getting an error

bash: /usr/lib/command-not-found: /usr/bin/python3: bad interpreter: No such file or directory

I couldnt opem ny terminal so I changed the very first line of /usr/bin/gnome-terminal to:

!#usr/bin/python from #!usr/bin/python3 since then I am able to open my terminal.
Upon entering sudo apt-get update I am getting this error

sh: 1: /usr/lib/cnf-update-db: not found
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code

No matter whether I enter




I am getting this error
bash: /usr/local/bin/pip: /usr/bin/python3: bad interpreter: No such file or directory

I tried sudo update-alternatives --config python3
I got There is only one alternative in link group python3 (providing /usr/bin/python3.6): /usr/bin/python3.7
Nothing to configure.

But when I type sudo update-alternatives --config python I am getting

There are 2 choices for the alternative python (providing /usr/bin/python).

Selection Path Priority Status

0 /usr/bin/python3.6 2 auto mode

* 1 /usr/bin/python3.6 2 manual mode

2 /usr/bin/python3.7 2 manual mode

The Software&Updates and Software Updater are also not loading when I click on their icon

Best Answer

  • python from your command line must point to python2.7

    You might have messed up your apt/aptitude

    Delete your symlink and replace with the default python

    sudo rm /usr/bin/python


    sudo ln -sf /usr/bin/python2.7 /usr/bin/python

    Similarly for Ubuntu 18.10 python3 points to python3.6

    sudo rm /usr/bin/python3


    sudo ln -sf /usr/bin/python3.6 /usr/bin/python3

    Hope this helps

  • Related Question