Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

I am trying to install g++.But not able to do it.

    amol@amol-System-Product-Name:~$ sudo apt-get install g++
[sudo] password for amol: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
apt-xapian-index : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 apturl : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 apturl-common : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 checkbox : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 command-not-found : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 duplicity : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 g++ : Depends: g++-4.6 (>= 4.6.3-1~) but it is not going to be installed
 gedit : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 gnome-orca : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 gnome-sudoku : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 gwibber : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 gwibber-service : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 hplip : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 hplip-data : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 ibus : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 ibus-pinyin : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 ibus-table : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 jockey-common : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 language-selector-common : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 language-selector-gnome : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 launchpad-integration : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 lsb-release : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 nvidia-common : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 onboard : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 oneconf : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python : Depends: python2.6 (>= 2.6.5) but it is not installable
      Depends: python-minimal (= 2.6.5-0ubuntu1) but 2.7.3-0ubuntu2.2 is to be installed
 python-appindicator : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-apport : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-apt : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-aptdaemon : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-aptdaemon.gtk3widgets : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-aptdaemon.pkcompat : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-brlapi : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-cairo : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-chardet : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-configglue : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-crypto : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-cups : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-cupshelpers : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-dateutil : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-dbus : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-debian : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-debtagshw : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-defer : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-dirspec : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-egenix-mxdatetime : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-egenix-mxtools : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-gconf : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-gdbm : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-gi : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-gi-cairo : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-gnomekeyring : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-gnupginterface : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-gobject-2 : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-gst0.10 : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-gtk2 : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-httplib2 : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-ibus : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-imaging : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-keyring : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-launchpadlib : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-lazr.restfulclient : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-lazr.uri : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-libproxy : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-libxml2 : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-louis : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-mako : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-markupsafe : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-notify : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-oauth : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-openssl : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-packagekit : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-pam : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-pexpect : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-piston-mini-client : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-problem-report : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-protobuf : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-pyatspi2 : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-pycurl : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-pyinotify : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-renderpm : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-reportlab : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-reportlab-accel : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-serial : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-simplejson : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-smbc : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-software-properties : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-speechd : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-twisted-bin : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-twisted-core : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-twisted-names : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-twisted-web : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-ubuntu-sso-client : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-ubuntuone-client : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-ubuntuone-control-panel : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-ubuntuone-storageprotocol : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-uno : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-virtkey : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 python-wadllib : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-xapian : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-xdg : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-xkit : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-zeitgeist : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 python-zope.interface : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 rhythmbox : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 rhythmbox-plugins : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 sessioninstaller : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 software-center : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 software-center-aptdaemon-plugins : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 software-properties-common : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 software-properties-gtk : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 totem : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 totem-plugins : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 ubuntu-sso-client-gtk : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 ubuntu-system-service : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 ubuntuone-couch : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 ubuntuone-installer : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 ufw : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 unity-lens-video : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 unity-scope-video-remote : Depends: python (>= 2.7) but 2.6.5-0ubuntu1 is to be installed
 update-manager : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 update-manager-core : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 usb-creator-common : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 usb-creator-gtk : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
 xdiagnose : Depends: python (>= 2.7.1-0ubuntu2) but 2.6.5-0ubuntu1 is to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
share|improve this question

marked as duplicate by Eliah Kagan, Kevin Bowen, Warren Hill, Eric Carvalho, Seth Aug 22 '13 at 15:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
You might want to run 'apt-get -f install' to correct these –  Vitalie Ciubotaru Aug 19 '13 at 2:07
    
i have even tried that but it is showing amol@amol-System-Product-Name:~$ apt-get -f install E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root? –  Amol Aug 19 '13 at 2:09
    
Unless you are root, you need to add 'sudo' at the beginning of your command. –  Vitalie Ciubotaru Aug 19 '13 at 2:11
    
@Vitalie Ciubotaru I have even tried that it is showing a very long list and after that there is an error E: Sub-process /usr/bin/dpkg returned an error code (1) –  Amol Aug 19 '13 at 2:14
    
So, this is embarrassing. We shouldn't have duped this to How do I resolve unmet dependencies?. The problem here is not that the package manager can't install dependencies declared by g++, but that it doesn't know about g++ at all (usually because the main repository got disabled), and so it's trying to match g++ as a pattern, selecting a long list of packages (that are not actually dependencies of g++, which should've been the clue). More info and solution here. –  Eliah Kagan Sep 9 at 19:51

1 Answer 1

Run

sudo apt-get update

first, then

sudo apt-get install g++
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.