July 29, 2021
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.
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.
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:
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:
But here we might get an error “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:
This command will add Python 3.7 on option 1.
Then we need to run following command:
This command will add Python 3.9 on option 2
We can see this on the following screenshot:
Now we can again run the configure command to check and set the alternatives:
In the following screenshot we can see that now we can save the configurations now.
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:
Now we can check python3 default version by using following command:
We can see that now our Python 3.9 version is set as default for python3 command:
“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.
Article posted by: https://www.kalilinux.in/2021/05/update-alternatives-error-no-alternatives-for-python3.html
Infocerts, 5B 306 Riverside Greens, Panvel, Raigad 410206 Maharashtra, India
Contact us – https://www.infocerts.com
This is the article generated by feed coming from KaliLinux.in and Infocerts is only displaying the content.