Cause
The yum command requires the system's default Python 2.x environment. If the default Python interpreter is changed to an incompatible Python 3.x version, yum fails due to syntax differences and module incompatibilities.
Solution
Log on to the ECS instance.
Go to ECS console - Instance. In the top navigation bar, select the target region and resource group.
Go to the details page of the target instance. Click Connect and select Workbench. Follow the prompts on the page to log on to the terminal.
Find the default
Python 2.xpath.sudo ls /usr/bin/python2* | head -n 1/usr/bin/python2In this example, the default
Python 2.xpath is/usr/bin/python2.Restore the default Python interpreter for the
yumcommand.Edit the first line of the
/usr/bin/yumfile:Before:
#!/usr/bin/pythonAfter:
#!<Path to the default Python 2.x version from the previous step>
For this example, change
#!/usr/bin/pythonto#!/usr/bin/python2.Re-run a
yumcommand to verify the fix. The command should now execute successfully.