making a pygtk package


as we use pytk for our game data editor we are trying to quickly get the editor up and running for others to use.
Simply using pygtk doesn’t work as the test p3d app fails with an ‘ImportError: No module named pygtk’ logged in p3dsession.log.

So as panda3d doesn’t have an already prebuild pygtk package I tried to build my own one based on thirdparty.pdef (wx specifically).

The code for the wannabe pygtk package is as follows:

import sys

# sys.path.insert(0,'F:/Development/Panda3D/1.8.0-dev/python/Lib/site-packages') 

class pygtk(package):
    config(display_name = "GTK2 GUI Toolkit")
    import pygtk
    import gtk

    module('pygtk', required = True)


This fails with ppackage as an ImportError: No module named pygtk occurs.

Only if I uncomment the “# sys.path.insert(0,‘F:/Development/Panda3D/1.8.0-dev/python/Lib/site-packages’)” line it seems to work.
As ppackage then prints Generating pygtk/

The question I have is - is this the correct way or what whould be the correct way to be able to use pygtk?

Greetings and thanks

I tried a simple hello world app with wx and get exactly the same error as described here:

And I’m on Windows XP atm.

When you run ppackage.p3d, it uses an internal version of Python and not the one you have in F:/Dvelopment/Panda3D/1.8.0-dev/python, so it won’t automatically be able to find your pygtk otherwise. Adding it to sys.path solves the problem nicely; I suppose that the usual approach is to add it to the PYTHONPATH environment variable or perhaps copy pygtk to the current directory before running ppackage.

If that works for you, then perhaps I could consider including pyGTK as one of the default packages on

Thanks for your help rdb!

Well it didn’t really work. ppackage build a package with these contents:

22.06.2013  02:43    <DIR>          .
22.06.2013  02:43    <DIR>          ..
22.06.2013  02:43                 0 package_contents.txt
22.06.2013  02:23             2.779 pygtk.win32.import.xml
22.06.2013  02:23         8.691.123
22.06.2013  02:23             5.566 pygtk.win32.xml

But the myapp.p3d cannot use it.
I used these commands to build the package and I copied pygtk and the gtk-2.0 directory from site-packages into the current directory -which wasn’t needed with adding the site-packages directory with sys.path.insert(0,…) etc. - it build the package with the contents as described above.

ppackage -i mypackages/output_dir mypackages/pygtk.pdef
packp3d -o myapp.p3d -d HelloApp -r pygtk -m -s mypackages/output_dir

With multify I can see that panda3d uses the wrong host for resolving the package:

<requires name="pygtk" host="" seq="2" />

I tried to copy the package into the panda3d runtime directory etc. but that didn’t help either.

How would I use this package without hosting it on a server?


You can’t. If you don’t wish to host it on a server, you should package pygtk into the .p3d itself (by making it a platform-specific .p3d). It won’t work on other platforms then, of course.

You could alternatively simply use a file:/// URL as the package location, by specifying the correct URL to the -r option to packp3d:

-r pygtk,,file:///path/to/location/of/pygtk/package/

Of course, that path will be hardcoded into the package and it won’t work on a system that doesn’t have it at that location.

Hi all,

so after a long hiatus I fiddled with my pdef for pygtk.
Thanks for the tip rdb, that works perfect for testing but it still doesn’t quiet work, I mean pygtk.

ppackage seems to build a pygtk package but it throws the following error in p3dsession.log:

:AppRunner: Total Panda3D disk space used: 250 MB
:AppRunner: Configured max usage is: 2048 MB
Traceback (most recent call last):
  File "C:\buildslave\release_rtdist_win32\build\panda3d\built_cmu\direct\showbase\", line 424, in __taskChainDispatch
  File "C:\buildslave\release_rtdist_win32\build\panda3d\built_cmu\direct\showbase\", line 482, in __dispatch
  File "C:\buildslave\release_rtdist_win32\build\panda3d\built_cmu\direct\p3d\", line 748, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "F:\Developement\Panda3D\Runtime\HelloApp\", line 18, in <module>
    import gtk
  File "VFSImporter", line 437, in load_module
  File "VFSImporter", line 153, in load_module
  File "F:\Developement\Panda3D\1.8.0-dev\python\Lib\site-packages\gtk-2.0\gtk\", line 30, in <module>
    import gobject as _gobject
  File "VFSImporter", line 437, in load_module
  File "VFSImporter", line 153, in load_module
  File "F:\Developement\Panda3D\1.8.0-dev\python\Lib\site-packages\gtk-2.0\gobject\", line 26, in <module>
    from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
  File "VFSImporter", line 437, in load_module
  File "VFSImporter", line 153, in load_module
  File "F:\Developement\Panda3D\1.8.0-dev\python\Lib\site-packages\gtk-2.0\glib\", line 23, in <module>
    _PyGLib_API = _glib._PyGLib_API
NameError: name '_glib' is not defined
:task(error): Exception occurred in PythonTask Messenger-default
Traceback (most recent call last):
  File "C:\buildslave\release_rtdist_win32\build\panda3d\built_cmu\direct\p3d\", line 638, in run
  File "C:\buildslave\release_rtdist_win32\build\panda3d\built_cmu\direct\task\", line 502, in run
  File "C:\buildslave\release_rtdist_win32\build\panda3d\built_cmu\direct\task\", line 460, in step
  File "C:\buildslave\release_rtdist_win32\build\panda3d\built_cmu\direct\showbase\", line 424, in __taskChainDispatch
  File "C:\buildslave\release_rtdist_win32\build\panda3d\built_cmu\direct\showbase\", line 482, in __dispatch
  File "C:\buildslave\release_rtdist_win32\build\panda3d\built_cmu\direct\p3d\", line 748, in __startIfReady
  File "VFSImporter", line 153, in load_module
  File "F:\Developement\Panda3D\Runtime\HelloApp\", line 18, in <module>
    import gtk
  File "VFSImporter", line 437, in load_module
  File "VFSImporter", line 153, in load_module
  File "F:\Developement\Panda3D\1.8.0-dev\python\Lib\site-packages\gtk-2.0\gtk\", line 30, in <module>
    import gobject as _gobject
  File "VFSImporter", line 437, in load_module
  File "VFSImporter", line 153, in load_module
  File "F:\Developement\Panda3D\1.8.0-dev\python\Lib\site-packages\gtk-2.0\gobject\", line 26, in <module>
    from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
  File "VFSImporter", line 437, in load_module
  File "VFSImporter", line 153, in load_module
  File "F:\Developement\Panda3D\1.8.0-dev\python\Lib\site-packages\gtk-2.0\glib\", line 23, in <module>
    _PyGLib_API = _glib._PyGLib_API
NameError: name '_glib' is not defined
Failure on startup.

I don’t know what the problem is with _glib but it’s in the mf file according to mf extraction and pygtk.win32.import.xml:

<?xml version="1.0" encoding="utf-8" ?>
<package name="pygtk" platform="win32" seq="2">
    <config display_name="GTK2 GUI Toolkit" />
    <uncompressed_archive filename="" size="20798698" timestamp="1386643119" hash="b4f18cefa6cdc50790c19b82528d2c38" />
    <compressed_archive filename="" size="8781814" timestamp="1386643122" hash="39a4369062d381e11aaeb38d5b33eb0e" />
    <extract filename="cairo/_cairo.pyd" size="69632" timestamp="1288722918" hash="46d708899832abc0123c4e9cb4f61d5d" />
    <extract filename="cairo/libcairo-2.dll" size="644562" timestamp="1351458414" hash="36ab2ee3250cf1e562c63f8c368c37b1" />
    <extract filename="cairo/libfontconfig-1.dll" size="237207" timestamp="1347873086" hash="ba953f65eea6ca574eae80c3529445a0" />
    <extract filename="cairo/libfreetype-6.dll" size="493606" timestamp="1346694900" hash="f34586fa0417f54fe9e5738137351748" />
    <extract filename="cairo/libpixman-1-0.dll" size="571650" timestamp="1346695112" hash="76bfd19720ea55f7e136e8fef1b03b8b" />
    <extract filename="cairo/libpng15-15.dll" size="177192" timestamp="1346694572" hash="3cc2869abf5606e1b9b80e346f162b90" />
    <extract filename="cairo/libxml2-2.dll" size="1161549" timestamp="1347867976" hash="f6ccde33cb367d69e64283fd12ddf37b" />
    <extract filename="cairo/Microsoft.VC90.CRT.manifest" size="524" timestamp="1365938751" hash="6bb5d2aad0ae1b4a82e7ddf7cf58802a" />
    <extract filename="cairo/mscoree.dll" size="297808" timestamp="1257574024" hash="08a73b0e7ee6e32983b5f9e540a8e380" />
    <extract filename="cairo/MSIMG32.DLL" size="4608" timestamp="1208148738" hash="dc4e223f5813150073fb5cc63d13293b" />
    <extract filename="cairo/msvcm90.dll" size="224768" timestamp="1365938752" hash="4a8bc195abdc93f0db5dab7f5093c52f" />
    <extract filename="cairo/msvcp90.dll" size="568832" timestamp="1365938752" hash="6de5c66e434a9c1729575763d891c6c2" />
    <extract filename="cairo/msvcr90.dll" size="655872" timestamp="1365938752" hash="e7d91d008fe76423962b91c43c88e4eb" />
    <extract filename="cairo/msvcrt.dll" size="323072" timestamp="1365938752" hash="886a6c3c185aaedecd00477f72279b07" />
    <extract filename="cairo/python27.dll" size="2206720" timestamp="1365938752" hash="df0ed44c6ea53d13ceb2b4a0911430eb" />
    <extract filename="cairo/zlib1.dll" size="107212" timestamp="1346694284" hash="a4118c72438dcb76c12e4ab164d9ee05" />
    <extract filename="gio/_gio.pyd" size="263168" timestamp="1302328756" hash="acb8c95fdc391079bebdf7d8685b0dbc" />
    <extract filename="gio/DNSAPI.DLL" size="149504" timestamp="1299135283" hash="8cd2a78cf917653768485e74f3b89c50" />
    <extract filename="gio/libffi-5.dll" size="51570" timestamp="1346694430" hash="af041abe2e07a74392d9ea6a1dd7b024" />
    <extract filename="gio/libgio-2.0-0.dll" size="1132172" timestamp="1351457586" hash="d68c650836221dbcdaa8954b9f552949" />
    <extract filename="gio/libglib-2.0-0.dll" size="1149982" timestamp="1351457586" hash="cae8c4822709e75d610141cea7f752fa" />
    <extract filename="gio/libgmodule-2.0-0.dll" size="46371" timestamp="1351457586" hash="27e3031c57e2b7e843468e3f23b02c4d" />
    <extract filename="gio/libgobject-2.0-0.dll" size="299795" timestamp="1351457586" hash="59eb8116b8bebd560f2a2f0675cc2405" />
    <extract filename="gio/libgthread-2.0-0.dll" size="39284" timestamp="1351457586" hash="7930458976020c57bea5570dad4d0911" />
    <extract filename="gio/libintl-8.dll" size="130181" timestamp="1346696220" hash="f0e0255ee440ff2151658bdb83c6c1eb" />
    <extract filename="gio/msvcrt.dll" size="343040" timestamp="1208148740" hash="c6a6e53a0c34ec87883137a6cb87ae5e" />
    <extract filename="glib/_glib.pyd" size="58368" timestamp="1302328746" hash="0de636503e43c4eb00e80927bc9bda97" />
    <extract filename="gobject/_gobject.pyd" size="113152" timestamp="1302328750" hash="3d05dd191361f83aa247b62c700fa04e" />
    <extract filename="gtk/_gtk.pyd" size="1882624" timestamp="1302328976" hash="bbb1d1e41bbebc6abf69bed719d50497" />
    <extract filename="gtk/libatk-1.0-0.dll" size="137204" timestamp="1351458596" hash="d4b35f51fb9515efbd3ff4d413e6355a" />
    <extract filename="gtk/libgdk-win32-2.0-0.dll" size="680068" timestamp="1351459500" hash="4c7a6212264057bd04d027a4a864600e" />
    <extract filename="gtk/libgdk_pixbuf-2.0-0.dll" size="273294" timestamp="1351458086" hash="10c6ace54eabe6155468b45799eee96a" />
    <extract filename="gtk/libgtk-win32-2.0-0.dll" size="3861054" timestamp="1351459500" hash="84568a53cf26985b5aae180d3ad6e807" />
    <extract filename="gtk/libjasper-1.dll" size="282742" timestamp="1346698860" hash="7ae88bf868801859982760babce727ec" />
    <extract filename="gtk/libjpeg-8.dll" size="221676" timestamp="1346696674" hash="37e4360da9bf80fa8413e556efc6a1ed" />
    <extract filename="gtk/liblzma-5.dll" size="158594" timestamp="1346700092" hash="7ec2aa834e39264f6763b9f2df30a6bf" />
    <extract filename="gtk/libpango-1.0-0.dll" size="281126" timestamp="1351458788" hash="aa3e7ab275c0c3f673663dd1679e5100" />
    <extract filename="gtk/libpangocairo-1.0-0.dll" size="82897" timestamp="1351458788" hash="5888d805e239ed963d7a8c9711db343c" />
    <extract filename="gtk/libpangoft2-1.0-0.dll" size="236998" timestamp="1351458788" hash="334ba76de6ee019cd7621e2fb0d1d22f" />
    <extract filename="gtk/libpangowin32-1.0-0.dll" size="90457" timestamp="1351458788" hash="0e44dea95b1422ac91fe5e16e857d5f7" />
    <extract filename="gtk/libtiff-5.dll" size="448770" timestamp="1346700458" hash="222c5905628f66ce47a3aaaea2bff7d5" />
    <extract filename="gtk/USP10.dll" size="406016" timestamp="1373449074" hash="bd1fcb7f89008c72589be3b81701ec33" />
    <extract filename="gtk/WINSPOOL.DRV" size="146944" timestamp="1208148790" hash="e12d149442bbfea6aa952327b2ea0079" />

panda used is:

I couldn’t find a newer runtime on the website.

I get the same wx error as Cytruss posted if I try a simple hello wx with -r wx:

import wx
  File "VFSImporter", line 446, in load_module

I really would love to use GTK for my game projects because I use GTK also with other languages.
The hello gtk test app works fine if run with pythonw.exe etc.


I don’t know about this error, but I’d been working on some bugfixes related to the module finder, so perhaps that applying them would help you as well. I’ll see if I can’t dig them up at some point in the near future.