How do I properly install GTK+ on Ubuntu 12.04 Precise?

22,652

Yes - it sounds like you also need the Python binding for GTK+

For example:

  • apt-get install python-gtk python-glade2

It's also possible that you have a configuration mismatch. Look at the advice in this link:

Share:
22,652
John Zeller
Author by

John Zeller

Updated on July 09, 2022

Comments

  • John Zeller
    John Zeller almost 2 years

    The Issue: I am trying to install GTK+ on Ubuntu 12.04, and while it seems to have installed, each time I attempt to run a python program which uses 'import gtk', I get the error:

    Traceback (most recent call last):
      File "gps_slip_map.py", line 3, in 
        import gtk
    ImportError: No module named gtk
    

    The python code for gps_slip_map.py can be found here

    What I've Done So Far: There are a few dependancies that I needed here: osm-gps-map and gtk+.
    In order to download osm-gps-map I used the command, from here:

    sudo apt-get install libosmgpsmap-dev python-osmgpsmap


    In order to download gtk+ I used the command, from here, post #9 by 'p0c4r1':

    sudo apt-get install gnome-core-devel build-essential libgtk2.0-dev libgtk2.0-doc devhelp

    I have installed both of these and when I attempt to again, I receive confirmation in the form of this message:

    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    libosmgpsmap-dev is already the newest version.
    python-osmgpsmap is already the newest version.
    gnome-core-devel is already the newest version.
    build-essential is already the newest version.
    libgtk2.0-dev is already the newest version.
    libgtk2.0-doc is already the newest version.
    devhelp is already the newest version.
    The following packages were automatically installed and are no longer required:
      language-pack-zh-hans yaml-cpp language-pack-kde-en libwxgtk2.6-0 language-pack-kde-zh-hans language-pack-kde-en-base libwxbase2.6-0 python-central language-pack-zh-hans-base
      language-pack-kde-zh-hans-base
    Use 'apt-get autoremove' to remove them.
    0 upgraded, 0 newly installed, 0 to remove and 165 not upgraded.
    

    A friend who is working with me on this project was able to simply install Ubuntu 12.04 Precise and use the command to install osm-gps-map. This worked for him and the software ran without throwing an ImportError. I did this same thing, and it is not working for me.

    Conclusion: Is someone able to help me figure out how to fix this ImportError?

    Update 1: It seems as though the PYHTONPATH is correct.... the command 'echo $PYTHONPATH' shows:

    PYTHONPATH: /usr/local/lib/python2.7/site-packages/

    But, when I use the command 'ls /usr/local/lib/python2.7/site-packages/', it seems as though there is NO GTK listed anywhere.

    dateutil                       ipython-0.14.dev-py2.7.egg-info  _mlt.so       numpy-1.6.2-py2.7.egg-info   pytz                 wx.pth
    freenect-0.0.0-py2.7.egg-info  matplotlib                       mlt_wrap.o    pylab.py                     README               wxPython_common-2.8.12.1-py2.7.egg-info
    freenect.so                    matplotlib-1.3.x-py2.7.egg-info  mpl_toolkits  pylab.pyc                    serial               wxversion.py
    IPython                        mlt.py                           numpy         pyserial-2.6-py2.7.egg-info  wx-2.8-gtk2-unicode  wxversion.pyc
    

    To me it seems like this is the issue, but I have no idea how to go about manually adding the proper file here so that I can import gtk. Does anyone have any idea how to do this?