Compare the python and python3 symlinks in /etc/alternatives/ (e.g. with ls -lF /etc/alternatives/python*.

My guess is that python points to python3.8 while python3 points to python3.10. Or vice-versa.

Is there any particular reason why you want python to run 3.8 instead of 3.10? if not, run update-alternatives again and set it to either auto (preferred) or to 3.10 (you'll run into the same problem in future when 3.11 or 3.12 or whatever is the latest auto version).

Or just make sure that the alternatives symlinks for python and python3 point to the same version of python.

Answer from cas on Stack Exchange
🌐
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 - # update-alternatives --remove python /usr/bin/python2.7 update-alternatives: removing manually selected alternative - switching python to auto mode update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode
🌐
GitHub
gist.github.com › rrmhearts › 5728df70d8ebafc1014a69183e3abaef
Python Switch Version · GitHub
# 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.4 2 update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode
Discussions

ubuntu - sudo update-alternatives --config . How to set the auto entry - Unix & Linux Stack Exchange
Therefore I tried to sudo update-alternatives --config python . This gives: Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/python3.10 2 auto mode * 1 /usr/bin/python3 1 manual mode 2 /usr/bin/python3.10 2 manual mode 3 /usr/bin/python3.8 ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
June 27, 2022
linux - How to update-alternatives to Python 3 without breaking apt? - Stack Overflow
Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.7 2 auto mode 1 /usr/bin/python3.6 1 manual mode 2 /usr/bin/python3.7 2 manual mode Press enter to keep the current choice[*], or type selection number: 1 update-alternatives: using ... More on stackoverflow.com
🌐 stackoverflow.com
How to set default Python version without --update-alternatives - Stack Overflow
Copy$ sudo update-alternatives --config python3 There are 2 choices for the alternative python3 (providing /usr/bin/python3). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.8 2 auto mode 1 /usr/bin/python3.6 1 manual mode 2 ... More on stackoverflow.com
🌐 stackoverflow.com
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
🌐
GitHub
gist.github.com › joesan › c947ac9c9c3b851f818b29fe20084fdf
update-alternatives for python3 on Ubuntu · GitHub
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2 $ sudo update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.5 2 auto mode 1 /usr/bin/python2.7 1 manual mode 2 /usr/bin/python3.5 2 manual mode Press <enter> to keep the current choice[*], or type selection number:
🌐
Linux Hint
linuxhint.com › update_alternatives_ubuntu
How to Use update-alternatives Command on Ubuntu – Linux Hint
Selection number 0 is auto. Selection number other than 0 is manual. Here, Selection number 1 is for Python 2 alternative and Selection number 2 is for Python 3 alternative. So, to select Python 2 alternative, press 1 and then press <Enter>. Python 2 should be set as the default alternative ...
Top answer
1 of 7
61

replace

[bash:~] $ sudo update-alternatives --install /usr/bin/python python \
/usr/bin/python2.7 2

[bash:~] $ sudo update-alternatives --install /usr/bin/python python \
/usr/bin/python3.5 3

with

[bash:~] $ sudo update-alternatives --install /usr/local/bin/python python \
/usr/bin/python2.7 2

[bash:~] $ sudo update-alternatives --install /usr/local/bin/python python \
/usr/bin/python3.5 3

e.g. installing into /usr/local/bin instead of /usr/bin.

and ensure the /usr/local/bin is before /usr/bin in PATH.

i.e.

[bash:~] $ echo $PATH
/usr/local/bin:/usr/bin:/bin

Ensure this always is the case by adding

export PATH=/usr/local/bin:$PATH

to the end of your ~/.bashrc file. Prefixing the PATH environment variable with custom bin folder such as /usr/local/bin or /opt/<some install>/bin is generally recommended to ensure that customizations are found before the default system ones.

2 of 7
47

Per Debian policy, python refers to Python 2 and python3 refers to Python 3. Don't try to change this system-wide or you are in for the sort of trouble you already discovered.

Virtual environments allow you to run an isolated Python installation with whatever version of Python and whatever libraries you need without messing with the system Python install.

With recent Python 3, venv is part of the standard library; with older versions, you might need to install python3-venv or a similar package.

$HOME~$ python --version
Python 2.7.11

$HOME~$ python3 -m venv myenv
... stuff happens ...

$HOME~$ . ./myenv/bin/activate

(myenv) $HOME~$ type python   # "type" is preferred over which; see POSIX
python is /home/you/myenv/bin/python

(myenv) $HOME~$ python --version
Python 3.5.1

A common practice is to have a separate environment for each project you work on, anyway; but if you want this to look like it's effectively system-wide for your own login, you could add the activation stanza to your .profile or similar.

🌐
Brentknigge
brentknigge.com › notes › linux › linux-update-alternatives
Update Alternatives
Here are several commands to help you see which version of Python you are using. (Please note that after performing the above steps, you will need to start a new command line terminal) ... The entry with the * is the currently selected alternative. auto mode is selected by default, and will choose the application version based on the priority.
🌐
Seiden Group
seidengroup.com › home › how update-alternatives manages multiple versions of python, node.js, and other open source packages
How Update-Alternatives Manages Multiple Versions of Python, Node.js, and other Open Source Packages - Seiden Group
March 14, 2023 - The following example retrieves all versions of python: Note the values for Priority; in automatic mode, the package having the highest priority when enrolled becomes the preferred alternative automatically.
Find elsewhere
🌐
SUSE
documentation.suse.com › fr-fr › sles › 15-SP6 › html › SLES-all › cha-update-alternative.html
update-alternatives: managing multiple versions of commands and files | Administration Guide | SLES 15 SP6
March 30, 2026 - When a new package with an alternative is installed, the new alternative is added to the system. Whether the new package's alternative is selected as the default depends on its priority and on the mode that is set. Packages with a higher version also have a higher priority. The alternatives system can operate in two modes: Automatic mode.
🌐
Medium
rem-baba.medium.com › python-version-switch-manager-f4e34b3c6d9e
Python version switch manager. The objective of this tutorial is to… | by Ramesh Babu Chayapathi | Medium
July 10, 2023 - $ sudo update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3 2 auto mode 1 /usr/bin/python2 1 manual mode 2 /usr/bin/python3 2 manual mode Press to keep the current choice[*], or type selection number: 1
🌐
Baeldung
baeldung.com › home › administration › setting the default python to python3
Setting the Default python to python3 | Baeldung on Linux
May 7, 2025 - $ sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.11 20 $ sudo update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/local/bin/python3.11 20 auto mode 1 /usr/bin/python3 10 manual mode 2 /usr/local/bin/python3 20 manual mode Press <enter> to keep the current choice[*], or type selection number:
🌐
Ask Ubuntu
askubuntu.com › questions › 1099776 › question-about-python-mapping-etc-alternatives-python
16.04 - Question about Python mapping (/etc/alternatives/python) - Ask Ubuntu
sudo update-alternatives --config python # My output in this case: [sudo] password for m93: There are 3 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/bin/python3.6 2 auto mode * 1 /usr/bin/python2.7 1 manual mode 2 /usr/bin/python3.5 1 manual mode 3 /usr/bin/python3.6 2 manual mode
🌐
GitHub
gist.github.com › GrowtopiaJaw › 7c5b7556c9b9a48aa68fe063107e1a5d
update-alternatives for python2 and python3 in Ubuntu 16.04.x · GitHub
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python2.7 2 sudo update-alternatives --config python3 There are 2 choices for the alternative python3 (providing /usr/bin/python3). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python2.7 1 auto mode 1 /usr/bin/python2.7 1 manual mode 2 /usr/bin/python3.5 2 manual mode Press <enter> to keep the current choice[*], or type selection number: 2
🌐
pythontutorials
pythontutorials.net › blog › how-to-update-alternatives-to-python-3-without-breaking-apt
How to Set Python 3 as Default with update-alternatives (Without Breaking apt) — pythontutorials.net
sudo update-alternatives --install <link> <name> <path-to-python3> <priority> <link>: Path to the python alias (almost always /usr/bin/python). <name>: Logical name for the alternative (use python). <path-to-python3>: Path to your Python 3 executable (find it with which python3, e.g., /usr/bin/python3.10). <priority>: A number (e.g., 10) to set priority (higher = default if auto-mode is enabled).
🌐
Claudia Kuenzler
claudiokuenzler.com › blog › 1301 › using-update-alternatives-avoid-python-bad-interpreter-point-to-python3
Using update-alternatives to avoid /usr/bin/python: bad interpreter and point python to python3
March 16, 2023 - root@linux:~# update-alternatives --install /usr/bin/python python /usr/bin/python3 1 update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode
🌐
LinuxConfig
linuxconfig.org › home › how to change python versions on raspberry pi
Switch Python Versions on Raspberry Pi Easily
October 23, 2023 - $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 1 update-alternatives: using /usr/bin/python3.9 to provide /usr/bin/python (python) in auto mode $ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 2 update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode
🌐
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 - There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.4 2 auto mode 1 /usr/bin/python2.7 1 manual mode 2 /usr/bin/python3.4 2 manual mode Press to keep the current choice[*], or type selection number: 1
🌐
TecAdmin
tecadmin.net › how-to-switch-python-version-in-ubuntu-debian
How to Change Default Python Version on Ubuntu & Debian
April 26, 2025 - update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode