Foreword
Your system may include multiple Python versions, the default alias for python
might be using a version that you don’t want to work with.
Use the following command to find out what Python binary executables are avaliable:
1 | $ ls /usr/bin/python* |
To check what is your default python version execute:
1 | $ python --version |
Change python default on per user basis
Open ~/.bashrc
file and add the following alias to change the default python executable:
1 | alias python='/usr/bin/python3.4' |
Re-login after you made the change.
1 | $ python --version |
Change python default system-wide
To change python version system-wide we can use update-alternatives
command. Logged in as a root user, first list all available python alternatives:
1 | $ update-alternatives --list python |
Adding alternatives
If you don’t have any alternatives, use the following command to add:
1 | $ update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 |
--install
is used to create a symbolic link. The number a the end is for setting the priority, the higher the number, the larger the priority.
Switch default
1 | $ update-alternatives --config python |
Remove alternatives
In case we no longer have an alternative python version installed, we can remove its update-alternatives
listing.
1 | $ update-alternatives --remove python /usr/bin/python2.7 |