Has anyone managed to install PyGTK on MacOS with PyInstaller?

275 views
Skip to first unread message

David Ripton

unread,
Jan 29, 2012, 12:06:04 AM1/29/12
to PyInstaller
PyInstaller (the latest from Git, 837446350) works great for
installing my PyGTK program on Windows. On Mac OS, it builds a single-
file executable, but when I run it, it crashes with a traceback:

$ ./slugathon.mac client
Traceback (most recent call last):
File "<string>", line 41, in <module>
File "/Users/dripton/pyinstaller/PyInstaller/loader/iu.py", line
490, in importHook
mod = self.doimport(nm, ctx, ctx + '.' + nm)
File "/Users/dripton/pyinstaller/PyInstaller/loader/iu.py", line
539, in doimport
exec co in mod.__dict__
File "/Users/dripton/Source/Slugathon/build/pyi.darwin/slugathon-mac/
outPYZ1.pyz/slugathon.gui.Connect", line 13, in <module>
File "/Users/dripton/pyinstaller/PyInstaller/loader/iu.py", line
490, in importHook
mod = self.doimport(nm, ctx, ctx + '.' + nm)
File "/Users/dripton/pyinstaller/PyInstaller/loader/iu.py", line
539, in doimport
exec co in mod.__dict__
File "/Users/dripton/Source/Slugathon/build/pyi.darwin/slugathon-mac/
outPYZ1.pyz/twisted.internet.gtk2reactor", line 35, in <module>
File "/Users/dripton/pyinstaller/PyInstaller/loader/iu.py", line
449, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "/Users/dripton/pyinstaller/PyInstaller/loader/iu.py", line
539, in doimport
exec co in mod.__dict__
File "/Users/dripton/Source/Slugathon/build/pyi.darwin/slugathon-mac/
outPYZ1.pyz/gobject", line 26, in <module>
File "/Users/dripton/pyinstaller/PyInstaller/loader/iu.py", line
449, in importHook
mod = _self_doimport(nm, ctx, fqname)
File "/Users/dripton/pyinstaller/PyInstaller/loader/iu.py", line
539, in doimport
exec co in mod.__dict__
File "/Users/dripton/Source/Slugathon/build/pyi.darwin/slugathon-mac/
outPYZ1.pyz/glib", line 22, in <module>
File "/Users/dripton/pyinstaller/PyInstaller/loader/iu.py", line
468, in importHook
raise ImportError("No module named %s" % fqname)
ImportError: No module named glib._glib


The non-PyInstaller version of my program works fine on Mac OS, so I
know GTK+, glib, and my other dependencies are there on the build
box. But it appears that _glib.so isn't getting included in the
PyInstaller build. Does anyone have a PyGTK program successfully
building on Mac OS with PyInstaller?

Hartmut Goebel

unread,
Feb 2, 2012, 11:46:02 AM2/2/12
to pyins...@googlegroups.com
Am 29.01.2012 06:06, schrieb David Ripton:
> The non-PyInstaller version of my program works fine on Mac OS, so I
> know GTK+, glib, and my other dependencies are there on the build
> box. But it appears that _glib.so isn't getting included in the
> PyInstaller build. Does anyone have a PyGTK program successfully
> building on Mac OS with PyInstaller?
Did you follow <http://www.pyinstaller.org/wiki/FAQ#IfThingsGoWrong>?

--
Schönen Gruß - Regards
Hartmut Goebel
Dipl.-Informatiker (univ.), CISSP, CSSLP

Goebel Consult
Spezialist für IT-Sicherheit in komplexen Umgebungen
http://www.goebel-consult.de

Monatliche Kolumne: http://www.cissp-gefluester.de/
Goebel Consult ist Mitglied bei http://www.7-it.de


David Ripton

unread,
Feb 2, 2012, 9:11:52 PM2/2/12
to PyInstaller
On Feb 2, 11:46 am, Hartmut Goebel <h.goe...@goebel-consult.de> wrote:
> Am 29.01.2012 06:06, schrieb David Ripton:> The non-PyInstaller version of my program works fine on Mac OS, so I
> > know GTK+, glib, and my other dependencies are there on the build
> > box.  But it appears that _glib.so isn't getting included in the
> > PyInstaller build.  Does anyone have a PyGTK program successfully
> > building on Mac OS with PyInstaller?
>
> Did you follow <http://www.pyinstaller.org/wiki/FAQ#IfThingsGoWrong>?

Yes.

I tried --onedir but it didn't seem to help.

ArchiveViewer.py shows glib._glib.so and libglib-2.0.0.dylib are in my
executable. But the import fails.

glib's __init__.py does "from glib._glib import *" to move functions
from the extension module into the main namespace. That may be
causing the confusion. But it works on Windows.

I tried adding a hook, but it didn't help.

Martin Zibricky

unread,
Feb 3, 2012, 9:35:42 AM2/3/12
to pyins...@googlegroups.com
David Ripton píše v So 28. 01. 2012 v 21:06 -0800:

> The non-PyInstaller version of my program works fine on Mac OS, so I
> know GTK+, glib, and my other dependencies are there on the build
> box. But it appears that _glib.so isn't getting included in the
> PyInstaller build. Does anyone have a PyGTK program successfully
> building on Mac OS with PyInstaller?

Does it work when you copy in --onedir mode the _glib.so to the dist
folder and when you rename it like

_glib.so -> glib._glib.so

?

David Ripton

unread,
Feb 3, 2012, 11:08:42 PM2/3/12
to PyInstaller
That does work, but then it finds a similar problem with
gobject._gobject.so When I copy _gobject.so into dist/ and rename it
gobject._gobject.so, then it complains about missing gdk. (Just gdk,
not gdk.so or anything like that.) When I create dist/gdk/__init__.py
or dist/gdk.py, I get "ImportError: cannot import name
DeprecationWarning"

So it appears that _glib.so was just the tip of the iceberg.

Martin Zibricky

unread,
Feb 5, 2012, 5:03:08 PM2/5/12
to pyins...@googlegroups.com
David Ripton píše v Pá 03. 02. 2012 v 20:08 -0800:

> That does work, but then it finds a similar problem with
> gobject._gobject.so When I copy _gobject.so into dist/ and rename it
> gobject._gobject.so, then it complains about missing gdk. (Just gdk,
> not gdk.so or anything like that.) When I create dist/gdk/__init__.py
> or dist/gdk.py, I get "ImportError: cannot import name
> DeprecationWarning"
>
> So it appears that _glib.so was just the tip of the iceberg.

May I know how did you install PyGTK? I would like to test it on my
machine.

David Ripton

unread,
Feb 6, 2012, 6:37:34 PM2/6/12
to PyInstaller
I used jhbuild. I think these are the exact steps:

On Mac OS 10.6 Snow Leopard
Download Xcode from Mac Dev Center and click the installer
Download http://git.gnome.org/browse/gtk-osx/plain/gtk-osx-build-setup.sh
sh gtk-osx-build-setup.sh
Add the following to your $HOME/.bash_profile: export PATH=:~/.local/
bin:~/gtk/inst/bin:$PATH
source $HOME/.bash_profile
sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2
sudo ln -s /usr/bin/g++ /usr/bin/g++-4.2
jhbuild bootstrap
jhbuild build python
jhbuild build meta-gtk-osx-bootstrap
jhbuild build meta-gtk-osx-core
jhbuild buildone pycairo
jhbuild build pygtk

Thanks.
Reply all
Reply to author
Forward
0 new messages