Make Python3 default without breaking yum in RHEL7
1
vote
1
answer
2626
views
> **What specific syntax needs to be changed or added to the below in order for commands calling
python
in a RHEL7 VM to be interpreted using Python3 WITHOUT breaking programs like yum
that require Python2?**
**FIRST ATTEMPT:**
Our first attempt was to add the following 2 lines to the very end of the cloud-init
startup script which instantiates the VM:
rm /usr/bin/python
ln -s /usr/bin/python3 /usr/bin/python
**ERROR THAT RESULTED:**
The problem is that adding the above two lines to the end of the cloud-init
startup script causes yum
commands to break when yum
is called afterwards as follows:
$ sudo yum update -y
File "/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
$
**TOGGLING THE ERROR:**
We can turn off the error by removing the above 2 lines from the cloud-init
startup script and re-instantiating a new replacement VM. This isolates the source of the problem, but still we have the problem of how to default python
to Python3 without breaking apps like yum
.
Asked by CodeMed
(5357 rep)
Jul 7, 2020, 05:24 PM
Last activity: Jul 27, 2025, 02:04 AM
Last activity: Jul 27, 2025, 02:04 AM