Blog
how to we know the available python version packages on fedora linux system?
$ ls /usr/bin/python*
Lists the available python version packages as below.
/usr/bin/python2 /usr/bin/python2.7-futurize /usr/bin/python3 /usr/bin/python3.6m /usr/bin/python2.7 /usr/bin/python2.7-pasteurize /usr/bin/python3.6 /usr/bin/python3-chardetect
Based on above, there are two python versions python 2.7 and python3.6 available in fedora system.
How to check the python default version in fedora
$ python -VOutput:
Python 2.7.15
By default python3 command is there to run the python3 code on fedroa system.
$ python3 -V Python 3.6.6
$ alias python='/usr/bin/python3.6'
Now default version for python command is using python3.6 version for current user.
$ python -V Python 3.6.6
but if you check the python default version in other user, this change will not be updated.
Let's check with root user
$ sudo -i # python -V Python 2.7.15
alternatives command is available in fedora to change the python version globally to all the users on fedara linux system.
alternatives syntax
alternatives --install[--initscript ] [--family ] [--slave ]* alternatives --remove alternatives --auto alternatives --config alternatives --display alternatives --set alternatives --list alternatives --remove-all
Let us first check whether any alternative python version is registered in the fedora system
$ alternatives --list | grep -i python
If no alternatives registered, nothing will be displayed.
To register the python alternatives, need to use alternatives with --intall option.
Creates the alternative python version for 3.6 with high priority 10
$ sudo alternatives --install /usr/bin/python python /usr/bin/python3.6 10
Creates the alternative python version for 2.7 with priority 1.
$ sudo alternatives --install /usr/bin/python python /usr/bin/python2.7 1
Once created alternative python versions, we can change the python version using alternatives command with --config option.
$ sudo alternatives --config python There are 2 programs which provide 'python'. Selection Command ----------------------------------------------- *+ 1 /usr/bin/python3.6 2 /usr/bin/python2.7 Enter to keep the current selection[+], or type selection number: 2
Here we have selected the python version 2.7, and check the default python version in fedora linux
$ python -V Python 2.7.15
Check the python version as root user as well.
$ sudo -i # python -V Python 2.7.15« Previous Next »
Blog
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page