Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


pygtk does not install correctly #16891

marcindulak opened this Issue · 20 comments

3 participants

marcindulak Samuel John Adam Vandenberg

This is problem reported originally at Homebrew/homebrew-science#53
pygtk related packages do not create correct links under /usr/local/include.
Creating links as listed above results in a matplotlib working with gdk backend
(no more "ImportError: No module named _backend_gdk")

marcindulak marcindulak referenced this issue in Homebrew/homebrew-science

pygtk does not install correctly #53

Samuel John

So there is the chance for an easy fix?


One has to set PKG_CONFIG_PATH correctly and additionally /usr/local/lib/pkgconfig/libffi.pc needs to be present (for some reasons it is not linked correctly from Cellar). So after libffi gets fixed, the correct variable would be:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
The second dir is due to #14123

Adam Vandenberg

If pygtk uses libffi, it should have depends_on 'libffi'.

Samuel John

I guess @adamv is right; would be great if you could test this @marcindulak :-)


The problem (or feature) of the libffi.pc file missing is due the libffi formula itself.
So the question is: do i need to set the PKG_CONFIG_PATH before building pip install matplotlib or
this should be happening automatically?

Samuel John

A good question. Does pip install matplotlib read the PKG_CONFIG_PATH at all? (I haven't tested)


Yes it does

Samuel John

Then, perhaps, I can make a formula for matplotlib in my homebrew-python repository. Homebrew sets the PKG_CONFIG_PATH correctly during a build (if the depends_on lists the needed libs)


I understand now: homebrew sets the variables only within its own environment, so PKG_CONFIG_PATH
is not known the the shell, and this means some brew installed packages are not fully functional outside of brew.
Users need to keep track of this and set the variables by hand: #6828
Additional information: doing brew link libffi links the libffi.pc under /usr/local/lib/pkgconfig as expected,
but i understand there is a good reason the link is not performed for libffi.

Samuel John

Yes, Homebrew cannot set variables outside of its own process. Otherwise it would need to mess around with you .profile or whatever shell you are using.

You can call brew sh to temporary get the environment brew is using. I think this sets up the PKG_CONFIG_PATH, too. But I think not for keg_only formulae. Because these can break many other builds because they overwrite stuff from OS X.

Often one can set the path to a specific .pc file. But not sure if matplotlib allows this.


I'm building pip install matplotlib outside of brew with:
export PKG_CONFIG_PATH=brew --prefix libffi/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:$PKG_CONFIG_PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
The X11 one is related to xquartz and there is some discussion here #14489

Samuel John

This is enough hassle. I am going to make a matplotlib formula in my homebrew-python tap.

Samuel John

Ok, here it comes:

brew tap samueljohn/python
brew install matplotlib --with-gtk

Let me know if there are any problems.

Samuel John

@marcindulak can you please give me feedback on the gtk backend in my matplotlib formula?

@adamv the pygtk formula has libffi indirectly in its deps, so I think it's okay.
This is more a matter of how to teach external python packages to use the one and not the other libffi, I think.

Therefore, in my opinion, we can close this. I am open for rants about my matlabformula in my repo :-)

Adam Vandenberg

@samueljohn there is a :tex requirement in core now

Adam Vandenberg

Closing in core; thanks.

Adam Vandenberg adamv closed this
Samuel John

@adamv I will note that down onto my todo list :-)


It looks to me that there are two problems in the matplotlib formula.
My perspective is the default OSX python:
1. line 69: PYTHONPATH is overwritten so matplotlib does not build with gtk (python -c "import gtk" fails if i add that to the install stage)
2. line 54: i think it should end with 'with-gtk'

Samuel John
Samuel John

@marcindulak you mean this line --> ?
True, I have less tested this with system python. Brewed python is fine. But I'll fix that.

To (2): Wow, good catch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.