Skip to content

Instantly share code, notes, and snippets.

@umardx
Last active February 6, 2019 14:54
Show Gist options
  • Save umardx/c0800340c6c8df4031ee5a5f0afa1432 to your computer and use it in GitHub Desktop.
Save umardx/c0800340c6c8df4031ee5a5f0afa1432 to your computer and use it in GitHub Desktop.

Change python version 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:

# apt-get update
# apt-get install python3.6
# update-alternatives --list python
update-alternatives: error: no alternatives for python

The above error message means that no python alternatives has been recognized by update-alternatives command. For this reason we need to update our alternatives table and include both python2.7 and python3.6:

# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode

# update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10
update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode
# curl https://bootstrap.pypa.io/get-pip.py | python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment