Yum因键盘中断错误而崩溃

问题描述 投票:20回答:4

我安装了较新版本的python(3.2.3)而不是Fedora16中可用的版本(python2.7)

现在yum停止工作。它显示以下错误。

[root@localhost yum-3.4.3]# yum
  File "/usr/bin/yum", line 30
   except KeyboardInterrupt, e:
                           ^
SyntaxError: invalid syntax

请告知如何解决错误。这将是有帮助的,因为我无法更新或安装任何包。

python-3.x redhat yum fedora16
4个回答
38
投票

因为qazxsw poi不支持qazxsw poi。你可以运行命令yum,在第一行将Python3更改为vi /usr/bin/yum。因此,您可以通过/usr/bin/python而不是/usr/bin/python2运行命令yum


13
投票

我猜你从源代码安装了Python 3.2.3,并使用“make install”作为最后一个命令。该命令具有使用新版本替换系统安装的版本命令“python”的不幸副作用。使用“make altinstall”不会取代“python”。

命令“python”只是“python2”的符号链接,而“python2”又是“python2.7”的符号链接。您应该能够通过执行以下命令来恢复“python”:

Python2

12
投票

当用户升级到python3时会发生此问题,只需编辑文件 - > / usr / bin / yum并将第一行更改为 - >“#!/ usr / bin / python2”

以上解决方案无法解决所有yum依赖问题,最好运行以下命令。

sudo ln -s / usr / local / bin / python3 / usr / bin / python3(将最新的python标记为python3)

sudo ln -sf /usr/bin/python2.7 / usr / bin / python(nake 2.7默认为python)

坦克,达曼


3
投票

谢谢Damanvir!更改/ usr / bin / yum中的行有效!

这有点偏离主题,可能会被删除,但它可能会帮助某人。

这些是我用于在Centos上安装Python 3.7并修复yum错误的步骤。

Python3下载

cd /usr/bin
sudo ln -s python2 python

要么

https://www.python.org/

make altinstall用于防止替换默认的python二进制文件/ usr / bin / python。

tar -xvf
./configure --enable-optimizations

make
make install

Remove the current symbolic link to the previous version

make altinstall

OUTPUT:rm:删除符号链接'python'? ÿ

Find the location of the new version

cd /usr/bin

Verify this is correct

rm python

Create a symbolic link to the location of the new version

whereis python3.7
 OUTPUT: python3: /usr/local/bin/python3.7

输出:Python 3.7.0

Yum commands will show the following error:

  /usr/local/bin/python3.7 --version
  OUTPUT: Python 3.7.0

Change the top line of this file from using python to python2

ln -s /usr/local/bin/python3.7 python

python --version

参考: File "/bin/yum", line 30 except KeyboardInterrupt, e: SyntaxError: invalid syntax

© www.soinside.com 2019 - 2024. All rights reserved.