我实际上有未满足的依赖关系

我实际上有未满足的依赖关系

尝试安装 python-gtk2 时,出现以下错误:

sudo apt-get install python-gtk2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 python-gtk2 : Depends: python (< 2.8) but 3.4.3-1 is to be installed
               Depends: python:any (>= 2.6.6-7~)
               Depends: python-cairo (>= 1.0.2-1.1) but it is not going to be installed
               Depends: python-gobject-2 (>= 2.21.3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

但是我安装了 python2.7。当我在终端中运行 python 时,它可以正常工作(Python 2.7.15rc1(默认,2018 年 4 月 15 日,21:51:34))。在这种情况下我该怎么办?我尝试过的方法包括:

  • sudo apt-get -f install

  • sudo apt-get update –fix-missing

  • sudo dpkg –configure -a

运行后sudo apt-cache policy python我得到以下输出:

sudo apt-cache policy python
python:
  Installed: 3.4.3-1
  Candidate: 3.4.3-1
  Version table:
 *** 3.4.3-1 100
        100 /var/lib/dpkg/status
     2.7.15~rc1-1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

答案1

最终有效的是:

sudo apt-get install python=2.7.15~rc1-1

然后,运行 apt-cache policy python 后,

python:
  Installed: 2.7.15~rc1-1
  Candidate: 2.7.15~rc1-1
  Version table:
 *** 2.7.15~rc1-1 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status

然后我就可以安装我的软件包了。我相信这会删除我的 python3.4。

相关内容