I am using Ubuntu. I want to make python3 be the default python version instead of python2. I tried many ways.

For example :

Open your .bashrc file nano ~/.bashrc. Type

alias python='python3'
alias pip='pip3'

on to a new line at the top of the file then save the file with ctrl+o and close the file with ctrl+x. Then, back at your command line type source ~/.bashrc. Now your alias should be permanent.

I also tried :

update-alternatives --remove python /usr/bin/python2
update-alternatives --install /usr/bin/python python /usr/bin/python3

But the problem didn't solve. How can I solve this issue ?

  • 3
    Please say which operating system you are using (which distribution) – Philip Couling Feb 6 at 8:50
  • 3
    Also, what exactly is the problem, and how does it manifest itself? – berndbausch Feb 6 at 8:52
  • see my answer here, that might help you. /usr/bin/python is usually just a symlink as well. – maddingl Feb 6 at 10:35
  • 1
    Be careful, I forced an upgrade once and nearly broke the installation because Ubuntu relies on a particular version. I managed to recover, but it was a pita. There is a python version manager which allow you to select which python environment to use for development, this avoids fiddling with the default installation. – X Tian Feb 6 at 10:35
  • github.com/pyenv/pyenv – X Tian Feb 6 at 10:38

Use a python version manager, don't fiddle with the OS dependent version.

Read the readme file at this repository for further information.

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