10

I installed meld in Mac OSX with Homebrew:

brew install meld

Then, when I run meld . it fails with the following error:

Cannot import: pygtk

No module named pygtk

However, pygtk is already installed:

brew install pygtk

Error: pygtk-2.24.0 already installed

5 Answers 5

7

The solution was to install PyGTK, directly from the pkg file in the repository:

http://sourceforge.net/projects/zero-install/files/PyGTK/2.24.0/org.pygtk.macosx.pkg/download

It worked flawlessly after that.

2
  • Wow it surely works after that. I first tried installing it through macports but that took so much time and in the end it didn't even work or maybe i couldn't figure out how to run it from terminal. But this options was simple. Thanks!
    – Rahul Dole
    Commented Aug 2, 2013 at 15:43
  • This also worked for the same error I was seeing running Diffuse after upgrading to High Sierra
    – Alastair
    Commented Mar 13, 2018 at 8:24
2

This seems to be the missing bit after installing using brew:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages
2
  • 1
    That's not working for me. :(
    – trusktr
    Commented Jan 27, 2015 at 3:37
  • 1
    Wait nevermind, starting xquartz first, then meld works.
    – trusktr
    Commented Jan 27, 2015 at 3:39
2

I found that pygtk is only part of the package. For meld to work you need to install the following:

XQuartz

brew uninstall cairo gtk+ pygobject py2cairo pygtk
brew tap phinze/homebrew-cask
brew install cairo gtk+
brew install py2cairo pygtk
brew install pygobject
brew install meld

Afterwards if you ls "/usr/local/lib/python2.7/site-packages/" you should see this:

Mac-Pro:~ user$ ls -la /usr/local/lib/python2.7/site-packages/ | grep pygtk
lrwxr-xr-x    1 user  admin      84 Mar  3 19:46 gtksourceview2.so -> ../../../Cellar/pygtksourceview/2.10.0/lib/python2.7/site-packages/gtksourceview2.so
lrwxr-xr-x    1 user  admin      70 Mar  5 01:04 pygtk.pth -> ../../../Cellar/pygobject/2.28.6/lib/python2.7/site-packages/pygtk.pth
lrwxr-xr-x    1 user  admin      69 Mar  5 01:04 pygtk.py -> ../../../Cellar/pygobject/2.28.6/lib/python2.7/site-packages/pygtk.py
-r--r--r--    1 user  admin    2075 Mar  5 01:05 pygtk.pyc
lrwxr-xr-x    1 user  admin      70 Mar  5 01:04 pygtk.pyo -> ../../../Cellar/pygobject/2.28.6/lib/python2.7/site-packages/pygtk.pyo

pygobject is actually the library that creates the pygtk library links that meld is looking for, I think the install order is important, as all of these packages were installed and meld failed to start with a missing pygtk library error.

When installed in the above order meld functioned flawlessly on two separate machines running Mavericks 10.9.2 which previously had a full environment setup in which meld reported no pygtk library when started.

I found this worked without needing to set PYTHONPATH, not to say that it isn't a bad idea.

To execute meld, simply open a terminal and execute:

meld

Edit: Added tap cask, install cask, required for cairo to install. Added brew install meld, added execution instruction.

0

I use macport to install meld on my Yosemite OSX 10.10 mac air. I encountered the same problem. @brablc 's method doesn't seem to work for me. Then I found this solution which works for me:

PYTHONPATH=/usr/lib/python2.7 meld &
2
  • That's not working for me. :(
    – trusktr
    Commented Jan 27, 2015 at 3:37
  • Wait nevermind, starting xquartz first, then meld works.
    – trusktr
    Commented Jan 27, 2015 at 3:38
0

I installed with brew. My Error was Cannot import: GTK+. To solve it, open terminal and enter:

rm /Applications/Meld.app/Contents/Frameworks/libz.1.dylib

After that, it works.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .