Installing meld: Cannot import: pygtk

10

2

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

alf

Posted 2012-07-30T19:55:20.660

Reputation: 271

Answers

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.

alf

Posted 2012-07-30T19:55:20.660

Reputation: 271

This also worked for the same error I was seeing running Diffuse after upgrading to High Sierra – Alastair – 2018-03-13T08:24:15.477

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 – 2013-08-02T15:43:35.007

2

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

export PYTHONPATH=/usr/local/lib/python2.7/site-packages

brablc

Posted 2012-07-30T19:55:20.660

Reputation: 1 102

1That's not working for me. :( – trusktr – 2015-01-27T03:37:31.780

1Wait nevermind, starting xquartz first, then meld works. – trusktr – 2015-01-27T03:39:57.697

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.

Joshua Briefman

Posted 2012-07-30T19:55:20.660

Reputation: 164

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.

lenooh

Posted 2012-07-30T19:55:20.660

Reputation: 131

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 &

David

Posted 2012-07-30T19:55:20.660

Reputation: 103

That's not working for me. :( – trusktr – 2015-01-27T03:37:57.443

Wait nevermind, starting xquartz first, then meld works. – trusktr – 2015-01-27T03:38:53.433