From the comment:

sudo update-alternatives --config python

Will show you an error:

update-alternatives: error: no alternatives for python3 

You need to update your update-alternatives , then you will be able to set your default python version.

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2

Then run :

sudo update-alternatives --config python

Set python3.6 as default.

Or use the following command to set python3.6 as default:

sudo update-alternatives  --set python /usr/bin/python3.6
Answer from GAD3R on Stack Exchange
Discussions

How do I change python version defaults?
I would really recommend against changing the default Python version. The operating system depends on it. Instead, usually the best approach for any serious work in Python is to use a Python version manager. I recommend Pyenv. It will allow you to switch Python interpreter without messing up with your system. To be sure, using a per-project version is not enough as you still jeopardize your system's Python dependencies. More on reddit.com
๐ŸŒ r/openSUSE
12
7
May 24, 2022
Switching between Python versions in Linux
Check what Python version are already installed - ls -ls /usr/bin/python* If the desired Python version is not installed, install it - sudo apt install python3.X In case of Couldn't find any package by glob 'Python-X.X.X' : sudo add-apt-repository ppa:deadsnakes/ppa Create the alternatives ... More on community.hailo.ai
๐ŸŒ community.hailo.ai
0
0
April 9, 2024
How can I switch default python version on command line?
I use "pyenv" for this. It is a package you install that lets you download different python versions and easily switch between them. More on reddit.com
๐ŸŒ r/learnpython
2
3
July 22, 2024
macos - How to change default Python version? - Stack Overflow
At the time, programs invoking ... the main version at the time). Extremely old systems may have programs and scripts which expect python=python2, and changing this would break those programs and scripts. At the time this answer was written, OP should not have changed this due to maintaining compatibility for old scripts. Nowadays, many years after the python2->python3 transition, most software explicitly refers to python2 or python3 (at least on Linux)... More on stackoverflow.com
๐ŸŒ stackoverflow.com
People also ask

How to know the available version of Python in Ubuntu/Debian?
By running thepython -Vcommand, the available version of Python will be displayed.
๐ŸŒ
operavps.com
operavps.com โ€บ docs โ€บ how to change python default version in debian/ubuntu
How to Change Python Default Version in Debian/Ubuntu
What is the most stable version of Python to use in Debian/Ubuntu?
Python 3.10 is the best and most stable version to use on Ubuntu and Debian.
๐ŸŒ
operavps.com
operavps.com โ€บ docs โ€บ how to change python default version in debian/ubuntu
How to Change Python Default Version in Debian/Ubuntu
๐ŸŒ
LinuxConfig
linuxconfig.org โ€บ home โ€บ how to change from default to alternative python version on debian linux
How to change from default to alternative Python version on Debian Linux
December 7, 2023 - Your Debian Linux installation may include multiple Python versions and thus also include multiple Python binary executables, and itโ€™s possible to change the python version that the system is using. In this tutorial, you will see how to install multiple versions of python, and change the python version on Debian using the update-alternatives python command.
๐ŸŒ
TecAdmin
tecadmin.net โ€บ how-to-switch-python-version-in-ubuntu-debian
How to Change Default Python Version on Ubuntu & Debian
April 26, 2025 - Create a symbolic link from /usr/bin/python2.7 to /usr/bin/python and set the group name as โ€œpythonโ€. This group name will be used to switch versions later. sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 ยท ...
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ administration โ€บ setting the default python to python3
Setting the Default python to python3 | Baeldung on Linux
May 7, 2025 - In this tutorial, letโ€™s look at how to set the default Python in our system based on our preferred Python version. Most Linux distros usually have the latest stable release of Python included as the default, and in older systems, the deprecated Python2.* is the default. Weโ€™ll see how we can change the default Python using the alias and update-alternatives commands.
Find elsewhere
๐ŸŒ
Medium
medium.com โ€บ coderlist โ€บ how-to-change-default-python-version-on-linux-fedora-28-c22da18bdd6
How to change default Python version on Linux/Fedora 28 | by Bartosz | Junior Dev Diaries | Medium
June 17, 2019 - $ alias python='/usr/bin/python3.6' $ python --version Python 3.6.8 ยท Thatโ€™s it. Pretty easy, right? Now letโ€™s have a deeper look at changing Python version globally.
๐ŸŒ
OperaVPS
operavps.com โ€บ docs โ€บ how to change python default version in debian/ubuntu
How to Change Python Default Version in Debian/Ubuntu
February 12, 2026 - Check the compatibility of Dependencies and Shebang Lines in your scripts with the newly set default Python version (for example, gnome-terminal is incompatible with 3.7) and change the shebang to explicitly point to a compatible version like 3.6. you can reinstall GNOME Terminal to ensure that it's properly configured with the new Python version. ... Let us know if you liked the post. Thatโ€™s the only way we can improve ... Pay for what you need with our scalable Linux VPS plans.
๐ŸŒ
LinuxVox
linuxvox.com โ€บ blog โ€บ linux-change-python-version
Linux: Changing Python Versions โ€” linuxvox.com
They provide an isolated environment for your project, allowing you to manage different Python versions and package dependencies independently. The update-alternatives command is a tool in Linux that allows you to manage alternative versions ...
๐ŸŒ
Hailo Community
community.hailo.ai โ€บ general discussion
Switching between Python versions in Linux - General Discussion - Hailo Community
April 9, 2024 - Check what Python version are already ... alternatives where X is the desired and Y is the main one: sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.X 1 sudo update-alternatives --install /usr/bin/python3 python3 ...
๐ŸŒ
RoseHosting
rosehosting.com โ€บ home โ€บ how to install and switch python versions on ubuntu 20.04
How to Install and Switch Python Versions on Ubuntu 20.04 | RoseHosting
October 5, 2022 - Before installing anything on your server it is recommended to update the system packages to their latest versions available. ... In the first step of this tutorial we are going to install the default Python2 and Python3 versions in Ubuntu 20.04.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-change-from-default-to-an-alternative-Python-version-on-Linux
How to change from default to an alternative Python version on Linux - Quora
Answer (1 of 5): When you develop with python, you really should consider environments, virtualenv or anaconda to name two. This allows you to install packages of different versions without filling your computer with packages that can conflict with some different packages. You can also lock down...
๐ŸŒ
DEV Community
dev.to โ€บ alfchee โ€บ how-to-switch-between-python-3-versions-5gh6
How to switch between Python 3 versions - DEV Community
September 2, 2020 - $ sudo apt update -y && sudo apt install python3.7 ยท Now we need to configure our update-alternatives in order to be able to switch of versions
๐ŸŒ
CloudBytes
cloudbytes.dev โ€บ home โ€บ snippets โ€บ upgrade python to latest version (3.14) on ubuntu linux or wsl2
Upgrade Python to latest version (3.14) on Ubuntu Linux or WSL2 ยท CloudBytes/dev
April 13, 2026 - A complete guide on how to upgrade Python to the latest version (Python 3.14) on Ubuntu Linux and solve associated issues. Also works on WSL2. Can also be used to upgrade to any Python version.
Top answer
1 of 16
185

[updated for 2021]

(Regardless if you are on Mac, Linux, or Windows:)

If you are confused about how to start the latest version of python, on most platforms it is the case that python3 leaves your python2 installation intact (due to the above compatibility reasons); thus you can start python3 with the python3 command.

Historically...

The naming convention is that generally, most scripts will call python2 or python3 explicitly. This happened due to a need for backwards compatibility.

Even though technically python doesn't even guarantee backwards compatibility between minor versions, Python3 really breaks backwards compatibility. At the time, programs invoking 'python' were expecting python2 (which was the main version at the time). Extremely old systems may have programs and scripts which expect python=python2, and changing this would break those programs and scripts.

At the time this answer was written, OP should not have changed this due to maintaining compatibility for old scripts.

Circa year 2021...

Nowadays, many years after the python2->python3 transition, most software explicitly refers to python2 or python3 (at least on Linux). For example, they might call #!/usr/bin/env python2 or #!/usr/bin/env python3. This has for example (python-is-python3-package) freed up the python command to be settable to a user default, but it really depends on the operating system.

The prescription for how distributions should handle the python command was written up in 2011 as PEP 394 -- The "python" Command on Unix-Like Systems. It was last updated in June 2019.

Regardless of whether you are writing a library or your program, you should specify the version of python (2 or 3, or finer-grained under specific circumstances) you can use in the shebang line, or since you're on OS X, in your IDE with which you are developing your app, so it doesn't mess up the rest of the system (this is what python venvs are for... download and search how to up set up a python3 venv on Mac if you're on a really really old version of OS X).

Shell alias:

You could, however, make a custom alias in your shell. The way you do so depends on the shell, but perhaps you could do alias py=python3, and put it in your shell startup file (.bashrc, .zshrc, etc). This will only work on your local computer (as it should), and is somewhat unnecessary compared to just typing it out (unless you invoke the command constantly).

Confused users should not try to create aliases or virtual environments or similar that make python execute python3; this is poor form.This is acceptable nowadays, but PEP 394 suggests encouraging users to use a virtualenv instead.

Different 3.* versions, or 2.* versions:

In the extremely unlikely case that if someone comes to this question with two python3 versions e.g. 3.1 vs 3.2, and you are confused that you have somehow installed two versions of python, this is possibly because you have done manual and/or manual installations. You can use your OS's standard package/program install/uninstall/management facilities to help track things down, and perhaps (unless you are doing dev work that surprisingly is impacted by the few backwards-incompatible changes between minor versions) delete the old version (or do make uninstall if you did a manual installation). If you require two versions, then reconfigure your $PATH variable so the 'default' version you want is in front; or if you are using most Linux distros, the command you are looking for is sudo update-alternatives. Make sure any programs you run which need access to the older versions may be properly invoked by their calling environment or shell (by setting up the var PATH in that environment).

A bit about $PATH

sidenote: To elaborate a bit on PATH: the usual ways that programs are selected is via the PATH (echo $PATH on Linux and Mac) environment variable. You can always run a program with the full path e.g. /usr/bin/๐Ÿ”ณ some args, or cd /usr/bin then ./๐Ÿ”ณ some args (replace blank with the 'echo' program I mentioned above for example), but otherwise typing ๐Ÿ”ณ some args has no meaning without PATH env variable which declares the directories we implicitly may search-then-execute files from (if /usr/bin was not in PATH, then it would say ๐Ÿ”ณ: command not found). The first matching command in the first directory is the one which is executed (the which command on Linux and Mac will tell you which sub-path this is). Usually it is (e.g. on Linux, but similar on Mac) something like /usr/bin/python which is a symlink to other symlinks to the final version somewhere, e.g.:

% echo $PATH
/usr/sbin:/usr/local/bin:/usr/sbin:usr/local/bin:/usr/bin:/bin

% which python
/usr/bin/python
% which python2
/usr/bin/python2
% ls -l /usr/bin/python
lrwxrwxrwx 1 root root 7 Mar  4  2019 /usr/bin/python -> python2*
% ls -l /usr/bin/python2  
lrwxrwxrwx 1 root root 9 Mar  4  2019 /usr/bin/python2 -> python2.7*
% ls -l /usr/bin/python2.7
-rwxr-xr-x 1 root root 3689352 Oct 10  2019 /usr/bin/python2.7*

% which python3         
/usr/bin/python3
% ls -l /usr/bin/python3
lrwxrwxrwx 1 root root 9 Mar 26  2019 /usr/bin/python3 -> python3.7*
% ls -l /usr/bin/python3.7
-rwxr-xr-x 2 root root 4877888 Apr  2  2019 /usr/bin/python3.7*

% ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       7 Mar  4  2019 /usr/bin/python -> python2*
lrwxrwxrwx 1 root root       9 Mar  4  2019 /usr/bin/python2 -> python2.7*
-rwxr-xr-x 1 root root 3689352 Oct 10  2019 /usr/bin/python2.7*
lrwxrwxrwx 1 root root       9 Mar 26  2019 /usr/bin/python3 -> python3.7*
-rwxr-xr-x 2 root root 4877888 Apr  2  2019 /usr/bin/python3.7*
lrwxrwxrwx 1 root root      33 Apr  2  2019 /usr/bin/python3.7-config -> x86_64-linux-gnu-python3.7-config*
-rwxr-xr-x 2 root root 4877888 Apr  2  2019 /usr/bin/python3.7m*
lrwxrwxrwx 1 root root      34 Apr  2  2019 /usr/bin/python3.7m-config -> x86_64-linux-gnu-python3.7m-config*
lrwxrwxrwx 1 root root      16 Mar 26  2019 /usr/bin/python3-config -> python3.7-config*
lrwxrwxrwx 1 root root      10 Mar 26  2019 /usr/bin/python3m -> python3.7m*
lrwxrwxrwx 1 root root      17 Mar 26  2019 /usr/bin/python3m-config -> python3.7m-config*

sidenote2: (In the rarer case a python program invokes a sub-program with the subprocess module, to specify which program to run, one can modify the paths of subprocesses with sys.path from the sys module or the PYTHONPATH environment variable set on the parent, or specifying the full path... but since the path is inherited by child processes this is not remotely likely an issue.)

2 of 16
142

Check the location of python 3

$ which python3
/usr/local/bin/python3

Write alias in bash_profile

vi ~/.bash_profile  
alias python='/usr/local/bin/python3'

Reload bash_profile

source ~/.bash_profile

Confirm python command

$ python --version
Python 3.6.5
๐ŸŒ
Namehero
namehero.com โ€บ blog โ€บ updating-python-version-on-linux-and-using-containers-as-an-alternative
Updating Python Version on Linux And Using Containers As An Alternative
November 6, 2024 - Open your shellโ€™s configuration file (e.g., ~/.bashrc, ~/.bash_profile, ~/.zshrc) in a text editor and add the following line:export PATH="/usr/local/python/bin:$PATH"Save the file and restart your terminal or run the source command on the configuration file for the changes to take effect. Installing Python from source gives you more control over the configuration and allows you to customize the installation according to your needs. However, it requires additional steps compared to using pre-built packages or containerization. In this blog post, we explored different methods for updating Python on a Linux system.