每一个问题都是机会

CentOS 7 yum install 出现 No such file or directory 错误的解决方案

CentOS 7 yum install 出现No such file or directory错误的解决方案:

[root@centos7 ~]# yum install -y git
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax

[root@centos7 ~]# yum
-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory

yum找不到/usr/bin/python。正常情况,应该是这个样子:

[root@centos7 ~]# ls -l /usr/bin/python
lrwxrwxrwx. 1 root root 7 Jul  9 11:08 /usr/bin/python -> python2
[root@centos7 ~]#

CentOS7 应该使用 python2,而不是 python3 来执行 yum

可能 默认 python 版本已更改为 python3。

查看Python2位置

[root@centos7 ~]# which python2
/usr/bin/python2

如果python2本身仍然存在,但/usr/bin/python符号链接丢失或者指向Python3,可以使用以下方法恢复:

[root@centos7 ~]# cd /usr/bin
[root@centos7 bin]# ln -s python2 python
[root@centos7 bin]# ls -l python
lrwxrwxrwx. 1 root root 7 Jul  9 11:10 python -> python2
[root@centos7 bin]#

这个解决方法有效!如果符号链接存在但是坏了,则我必须删除坏的符号链接,然后在执行上面代码恢复。

赞(0)
未经允许不得转载:技术好学屋 » CentOS 7 yum install 出现 No such file or directory 错误的解决方案
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址