I have installed python 3.6 on my CentOS machine by following the guide at https://linuxize.com/post/how-to-install-python-3-on-centos-7/, which installs python 3 with the following:
sudo yum install rh-python36
The default python version, however, is still python 2. The guide mentions I can run python 3 by first running scl enable rh-python36 bash
, and then python 3 will be used. However, this only works for that session - logging out and back in will revert back to python 2. According to How to set Python3.5.2 as default Python version on CentOS?, python 3 can be set as the default with the following:
sudo ln -fs /usr/bin/python3 /usr/bin/python
However, this doesn't work for me as for some reason I don't have any python3 file in /usr/bin/
- I only have python
, python2
, python2.7
, python2.7-config
, python2-config
and python-config
(despite installing python 3 with yum as above).
Copyright Notice:Content Author:「ZhouW」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58369453/set-python-3-as-default-python-version-in-centos