本来打算升级下系统所有软件包,居然发现yum无法使用了。提示第三十行错误。
0 1 2 3 |
[byrd@nginx ~]$ yum upgrade File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ |
原来是由于升级了默认的python导致的后果,《升级Centos 6.4 默认Python》。问题找到,那么就比较容易解决了。SourceByrd's Weblog-https://note.t4x.org/error/file-yum-except-keyboardinterrupt/
方法一:修改python版本到默认版本;
0 1 2 |
[root@nginx ~]# vim /usr/bin/yum #将!/usr/bin/python改成!/usr/bin/python2.6即可。 /usr/libexec/urlgrabber-ext-down #我测试不要改,网络资料有说需要改,请自行判断 |
方法二:修改python脚本;这个貌似不可行。
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
[root@byrd ~]# /usr/local/python3/bin/2to3-3.3 /usr/bin/yum RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma RefactoringTool: Refactored /usr/bin/yum --- /usr/bin/yum (original) +++ /usr/bin/yum (refactored) @@ -3,7 +3,7 @@ try: import yum except ImportError: - print >> sys.stderr, """\ + print("""\ There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: @@ -20,13 +20,13 @@ the yum faq at: http://yum.baseurl.org/wiki/Faq -""" % (sys.exc_value, sys.version) +""" % (sys.exc_info()[1], sys.version), file=sys.stderr) sys.exit(1) sys.path.insert(0, '/usr/share/yum-cli') try: import yummain yummain.user_main(sys.argv[1:], exit_code=True) -except KeyboardInterrupt, e: - print >> sys.stderr, "\n\nExiting on user cancel." +except KeyboardInterrupt as e: + print("\n\nExiting on user cancel.", file=sys.stderr) sys.exit(1) RefactoringTool: Files that need to be modified: RefactoringTool: /usr/bin/yum |
申明:本文由BYRD原创(基于Centos6.4 X64),未经许可禁止转载!SourceByrd's Weblog-https://note.t4x.org/error/file-yum-except-keyboardinterrupt/ SourceByrd's Weblog-https://note.t4x.org/error/file-yum-except-keyboardinterrupt/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!