This blog is NOT OFFICIAL website of Kali Linux. We just share Tutorials to learn Cybersecurity.

Set Default Version of Python : [SOLVED] update-alternatives: error: no alternatives for python3


On our Kali Linux (or any other Linux distribution) we might have installed different versions of Python. For using Python version 2.x we generally use python2 command, same as for using Python 3.x versions we use python3 command.

update alternatives: error no alternatives problem solved Linux
Here assume that we have installed multiple versions of Python3 installed on our system, like we have installed Python3.7 and Python 3.9 both on our Linux system for any reason. So whenever we want to use Python 3.9 we need to type command python3.9 because python3 command using Python 3.7 version as default.

python default version is lower
Our advanced Linux users may know this problem and the solution, but this is for beginners.

How to check installed Python versions on Linux?

This can be easily done with a simple command on our Terminal window. The command is following:

ls /usr/bin/python*

In the following screenshot we can see that we have Python2.7, Python3.7 and Python3.9 installed on our system.


But we can see that python3 command is choosing Python3.7 version as default. But some updated tools needs Python3.9 to run. We can run python3.9 command, but it is annoying we should run python3 to run Python3 latest version, we may modify our .bashrc/.zshrc file but that will not be the correct solution.

We need to set our update-alternatives for python3.

We can check for the alternatives of python3 by running following command:

sudo update-alternatives --config python3

But here we might get an error "update-alternatives: error: no alternatives for python3".

update-alternatives: error: no alternatives for python3
It means, first we need to set alternatives for python3.


To set the alternatives for python3 we need to run some commands on our terminal.

First of all we need to run the following command:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1

This command will add Python 3.7 on option 1.

Then we need to run following command:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 2

This command will add Python 3.9 on option 2

We can see this on the following screenshot:

Python Alternatives set

Now we can again run the configure command to check and set the alternatives:

sudo update-alternatives --config python3

In the following screenshot we can see that now we can save the configurations now.

python3 alternatives
Here we can set the default version for the python3. Here automatically 0 is chosen for Python 3.9 version, we can go for it, otherwise instead of choosing by numbers we can run following command to choose the default python3 version:
sudo update-alternatives  --set python3 /usr/bin/python3.9

Now we can check python3 default version by using following command:

python3 -V

We can see that now our Python 3.9 version is set as default for python3 command:

python3 latest version set as default

"update-alternatives: error: no alternatives for python3" is a very common problem for beginners so we thought to write an entire article for it we got too much request to solve this on our Telegram DM. When Python 4 will release some versions of Python 4, we can use the same as we did for Python 3.

Love our articles? Make sure to follow us to get all our articles directly on inbox. We are also available on Twitter and GitHub, we post article updates there. To join our family, join our Telegram Group. We are trying to build a community for Linux and Cybersecurity. For anything we always happy to help everyone on the comment section. As we know our comment section is always open to everyone. We read each and every comment and we always reply.

Kali Linux


No comments
Post a Comment