1

When trying to install python-gtk2, I get the following errors:

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.

But I have python2.7 installed. When I run python in terminal, it works properly (Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)). What should I do in this situation? Things I have tried include:

  • sudo apt-get -f install

  • sudo apt-get update –fix-missing

  • sudo dpkg –configure -a

After running sudo apt-cache policy python I get this output:

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
karel
  • 114,770
  • The python-gtk depends on python being installed (version less than 2.8, but you are going to install 3.4.3-1 which is not less than 2.8). You haven't told us what Ubuntu you are using, as all supported releases of Ubuntu contain a python package that meets the first 'dep' rule (https://packages.ubuntu.com/search?keywords=python). (https://packages.ubuntu.com/bionic/python-gtk2) – guiverc Jul 26 '18 at 05:54
  • @guiverc I am running Ubuntu 18.04, and have python 2.7.15 (which is version less than 2.8, so shouldn't it work out?) – QCD_IS_GOOD Jul 26 '18 at 05:58
  • sudo apt-cache policy python will probably show something in your sources that will cause 3.4.3-1 listed in your error message to be loaded.. Please add the output of that command to your question. – guiverc Jul 26 '18 at 05:59
  • @guiverc I ran it, and added it to my question – QCD_IS_GOOD Jul 26 '18 at 06:01
  • 1
    Your sources show the correct package available (2.7.15~rc1-1) from a valid source; however you've installed 3.4.3 (and rules mean you don't 'upgrade' to a lesser package), so the 3.4.3-1 you've already installed (from somewhere not shown in your current sources unless you edited the output from the apt-cache) have created that issue. I just picked another package (https://packages.ubuntu.com/bionic/python-cairo) and it should also have been no problem; it feels like you're not running Ubuntu (or you've heavily modified it creating problems...) I'd check your sources for non-Ubuntu .. – guiverc Jul 26 '18 at 06:08

1 Answers1

0

What ended up working was:

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

Then, after running 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

and I could install my package. This had the effect of removing my python3.4 I believe.