Wednesday, November 13, 2013

File "/usr/bin/yum", line 31 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax

I was getting the "invalid syntax" error with yum

[root@isvx3 ~]# yum
  File "/usr/bin/yum", line 31
    except KeyboardInterrupt, e:
                            ^
SyntaxError: invalid syntax
[root@isvx3 ~]#
[root@isvx3 ~]#

I found that the error started after I upgraded the python on the machine to 3.3.2

[root@isvx3 ~]# python -V
Python 3.3.2
[root@isvx3 ~]#

[root@isvx3 ~]# vim $(which yum)
#!/usr/bin/python

import sys
try:
    import yum
except ImportError:
    print >> sys.stderr, """\
..........................
..........................

The fix for this is to use the older version of python, which in my case was Python 2.4.3

[root@isvx3 ~]# /usr/bin/python2.4 -V
Python 2.4.3


[root@isvx3 ~]# more $(which yum)
#!/usr/bin/python2.4

import sys
try:
    import yum
except ImportError:
    print >> sys.stderr, """\
.............................
..............................




1 comment:

Anonymous said...

Thank you