3

I tried to make Python 3 the default Python version by running:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10

This broke Python 2 programs, so I tried reversing the process and finally I tried:

sudo update-alternatives --install /usr/bin/python python2.7 /usr/bin/python2.7 10

which made python2.7 the default Python version but Software Updater doesn't run and running aptdcon in a terminal gives:

bash: /usr/bin/aptdcon: /usr/bin/python3: bad interpreter: No such file or directory

I tried reinstalling Python 3 but got:

Errors were encountered while processing:
 /var/cache/apt/archives/python3_3.4.0-0ubuntu2_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

How do I revert this mess?

3

I managed to solve the issue myself. The problem was the broken symlink in /usr/bin

First I identified where python3 is. I guessed that the python3 binary would be in a similar folder as python2. So I typed ls -l /usr/bin/python.

This gave me /usr/bin/python -> /etc/alternatives/python2.7.

Since in /etc/alternatives/ there was no python3, I repeated the process

ls -l /etc/alternatives/python2.7 gave

/etc/alternatives/python2.7 -> /usr/bin/python2.7

A simple ls /usr/bin/python* listed all the python binaries available. The one I was interested in was python3.4.

Then I simply created a symlink with sudo ln -s /usr/bin/python3.4 /usr/bin/python3.

Problem solved.

  • You are diverging from the Ubuntu standard where they say they will not do this: /usr/bin/python will point to Python 3. No, this is not going to happen. One view is to think python2 and python3 are different languages with different syntax, not variations of the same language, so Ubuntu's decision to not imply that either in /etc/alternatives or /usr/bin/python seems to take this strong view. – maxpolk Dec 7 '15 at 22:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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