Centos系统yum运行时报错的问题解决
介绍
1.使用云服务器自带的,本来是自带yum的,但是我要运行Django项目,就自己安装了python3.10解释器.
2.安装完了发现yum不能用了,就是执行的时候会报错!
[root@VM-16-17-centos yum]yum install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized
File "/usr/libexec/urlgrabber-ext-down", line 28
except OSError, e:
^^^^^^^^^^
SyntaxError: multiple exception types must be parenthesized
走的弯路
- 我也不懂,就真的傻乎乎的去修改错误的源文件,改了好几个,最后发现还是不行.运行有错误
- 然后又去重装了yum,运行时还会有错误,真的难受
解决思路
后来在网上查资料时候发现是因为python版本会对yum有影响.因为我安装了python解释器,又把python软链接命令设置的解释器为python3.10的解释器.所以yum就依据python3.10去运行,结果一大堆语法错误,因为人家是基于python2.7运行的!!!
解决办法
把yum运行的解释器改成2.7就好啦~
先确定你的centos系统里面有没有2.7
python2.7 -V
输出的是版本信息,那就有(系统应该是自带的)
修改 /usr/bin/yum 文件第一行
#!/usr/bin/python2.7
修改/usr/libexec/urlgrabber-ext-down文件第一行
#!/usr/bin/python2.7
解决~~~