All Products
Search
Document Center

:Resolve the File "/usr/bin/yum",line 30 error when running yum on a Linux instance

Last Updated:Nov 12, 2025

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

  1. Log on to the ECS instance.

    1. Go to ECS console - Instance. In the top navigation bar, select the target region and resource group.

    2. 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.

  2. Find the default Python 2.x path.

    sudo ls /usr/bin/python2* | head -n 1
    /usr/bin/python2

    In this example, the default Python 2.x path is /usr/bin/python2.

  3. Restore the default Python interpreter for the yum command.

    Edit the first line of the /usr/bin/yum file:

    • Before: #!/usr/bin/python

    • After: #!<Path to the default Python 2.x version from the previous step>

    For this example, change #!/usr/bin/python to #!/usr/bin/python2.
  4. Re-run a yum command to verify the fix. The command should now execute successfully.