0

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

pip

or

pip3

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

  • 1
    Can you explain what changes you made (or attempted to make, but failed) to the system-provided Python and Python3? And what you were trying to accomplish with those changes? – user535733 May 22 at 18:17
  • I was trying to upgrade to 19.04 but I got an error something like "Your python3 install is corrupted. Please fix the '/usr/bin/python3' symlink. – learner May 22 at 18:19
  • So I entered the following command(copy-pasted from the community) sudo rm /usr/bin/python3 then sudo ln -sf /usr/bin/python3.6 /usr/bin/python3 then sudo update-alternatives --install /usr/bin/python3.6 python3 /usr/bin/python3 2 and finally sudo update-alternatives --config python3 – learner May 22 at 18:21
  • I followed this answer askubuntu.com/questions/1144048/… – learner May 22 at 18:21
  • I ran sudo apt install --reinstall python3-minimal everything went back to normal, but still not able to upgrade to 19.04 , when I ran "sudo do-release-upgrade' I still get "Your python3 install is corrupted. Please fix the '/usr/bin/python3' symlink. " – learner May 22 at 18:31
1

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

and

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

and

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

Hope this helps

  • Now can I upgrade to 19.04 – learner May 22 at 18:55
  • Try doing that and after upgrade just make sure python and python3 points to the correct symlinks. – z3phyr May 22 at 19:00
  • was it working?@learner – z3phyr Jun 10 at 16:20
  • yes it worked, thanks for the help :) – learner Jun 11 at 4:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.