Is there a way to set the Python 3.5.2 as the default Python version on CentOS 7? currently, I have Python 2.7 installed as default and Python 3.5.2 installed separately.
I used the following commands
mv /usr/bin/python /usr/bin/python-old
sudo ln -fs /usr/bin/python3 /usr/bin/python
but after that yum
gives the error.
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory
is there something I'm missing here?
NOTE: its the similar but opposite question of Linux CentOS 7, how to set Python2.7 as default Python version?
As the question goes, Linux CentOS 7, how to set Python3.5.2 as default Python version?
Will like to complement @OldFart's answer( Unforunately, can't comment else I would have).
when using the install param with update-alternatives, you can set the priority in auto mode. Implicitly saying that the alternative with the highest priority will be the default alternative should no alternative have been set manually. using the above answer as an example,
will set the python2 alternative with a priority of 50, and
will set the python3.5 alternative with a priority of 60. and by default, the python 3.5 becomes the default python executable for the python command.
should you want to change your default python alternative,
Find this a better approach as i don't have to modify my path files.
If this
doesn't work (it should)
you could just add an alias into your
/home/.bashrc
with this command:and if this does not work either you should just use virtual env. Read this page to get started.
I would suggest using 'alternatives' instead. As super-user (root) run the following:
The last command will ask you to choose between both alternatives.
As always, well most of the time anyways, you can check out the manual (manpages) using this simple command
Cheers