Installing Python & PyGTK on Mac OsX

Recently i have been asked to develop an application that will work on Linux, and Mac os, so i started developing it on my Ubuntu, i chosed Python as the programming language and PyGTK as the GUI for it.

The application worked fine on my Ubuntu, but when i moved it to Mac OSx (Leopard), i had a problem importing the PyGTK module and the program GUI didn’t run. so i tried to install PyGTK from sources with all its dependencies, but after spending a day doing so i ended up with many errors in compiling the dependencies and finding them.

after some search i found out that i can do this using MacPorts.

so here is the steps i followed :

– Install X11

– Install Xcode tools

– Install MacPorts

– Make sure the paths are configured in your shell profile

– Restart your shell, and follow the next commands :

1- Install Python

sudo port -v install python25

2- Install Python select

sudo port -v install python_select

3- Activate our installed python version

sudo python_select python25

4- Install pygtk

sudo port -v install py25-gtk

5- Install some gnome themes and engines

sudo port -v install gnome-themes
sudo port -v install gtk-nodoka-engine
sudo port -v install gtk-smooth-engine
sudo port -v install gtk2-aurora
sudo port -v install gtk2-clearlooks
sudo port -v install gtk2-extra
sudo port -v install gtk2-industrial
sudo port -v install gtk2-murrine

6- Install theme switch

sudo port -v install gtk-theme-switch

7- Select which theme to be used by your applications by running the theme switch


Now you can have the applications you develop using python and pygtk running smoothly on mac os leopard.

13 Responses to Installing Python & PyGTK on Mac OsX

  1. David says:

    Well, thank you so much. Wanting to try PyGtk on my brand new MacBook, I was afraid of having to compile so many packages by hand.

    One note though: be ready for several hours of compilation and a possible Xcode upgrade (3.1 required).

    Thanks once again,

  2. Asyclalay says:

    How do you look for information for your blog content?

  3. Me2resh says:

    u r welcome David 🙂

    i have had the bad experience trying to compile each package, it was horrible, but macports saved me 🙂

  4. Me2resh says:


    i write them myself based on real experience.

  5. Dominic says:

    Thanks a lot!

    I searched for hours after I installed py-gtk2 instead of py25-gtk:

    >>> import pygtk

    "ImportError: No module named pygtk"

  6. John D says:

    Step one fails on Snow Leopard:

    (four or six traceback lines)

    ImportError: No module named _Res

    make[1]: *** [installmacsubtree] Error 1

    make: *** [frameworkinstallmaclib] Error 2

    Any clue on this?

  7. dilip says:

    import pygtk fails ? any suggestions ? help would be great

  8. ZaFhieL says:

    Compadre tu explicacion no sirve!!!!! mejor contestame en snow leopard hay q hacer algo similar o ya esta funcionando al 100%?

  9. Xiao says:

    Thanks! nice article, was getting tired of how bland gtk looked on mac

  10. kalle says:

    Thank you!

    I could not get python_select to understand there was any other Python 2.5 than my apple-python25 even though I've installed Macports python25. Attempted using apple-python25 but failed misserably to build py25gtk.

    Everything worked out just fined when trying with python26 and py26gtk.

  11. Xiao says:

    Would you know how to make the theme switch work for su as well? If I open a GTK app using sudo, it goes back to the original theme

  12. Ryan says:

    Not sure if this is because I am getting Python 2.6 with 'port', but it failed to compile py26-gtk until I installed MacTeX.

  13. Wey says:

    How to add .profiles ?

    Warning: No index(es) found! Have you synced your source indexes?

    Error: Port python25 not found


Leave a Reply

Your email address will not be published. Required fields are marked *