py2exe and jp windows


I thought I'd mention some small isuues I found with using py2exe to deploy matplotlib 0.63.2 on Japanese Windows 2000.

* pytz seems to need a copy of C:\Python23\Lib\site-packages\pytz\zoneinfo in the installed folder, otherwise it gives a KeyError on UTC when matplotlib is imported

* pygtk.require() is not compatible with py2exe, so I added a wrapper to to check for freezing:

if not hasattr(sys, 'frozen'):
          # Don't want to check this for py2exe
          import pygtk
         print sys.exc_info()[1]
         raise SystemExit('PyGTK version 1.99.16 or greater is required to run the GTK/GTKAgg Matplotlib backend')

* throws an exception, I suspect to do with Japanese font names or font directory names:

File "c:\Python23\lib\site-packages\matplotlib\", line 111, in
     key, direc, any = _winreg.EnumValue( local, j)
WindowsError: [Errno 234]

from this site:

I found a workaround to add

local = None

at line 107 of to give this:

     for fontdir in MSFontDirectories:
             local = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, fontdir)
         except OSError:

         local = None

         if not local:
             return glob.glob(os.path.join(directory, '*.'+fontext))

* gtk 2.2.? was crashing (segfault) on Japanese Win2k so I upgraded to the latest (2.4.13) and now it seems to work. However now I get various dprecation warnings about the GTK toolbar when I show a plot. And IPython seems to break with GTK 2.4.x.

* Generally getting it all to work required quite a bit of fiddling and munging various recipes I found on email lists and in the pygtk FAQ. This included copying the matplotlib shared data into the installation and experimenting with different locations for it, and copying the gtk runtime into the installation and modifying the path within python so it could be found.

Thanks for matplotlib!