フローズンバイナリの作成(2)

id:Megumi221:20080312 のエラー。検索してみると海外で同じことで悩んでいる人はたくさんいるようだ。解決策は、http://www.py2exe.org/index.cgi/MatPlotLib ここが詳しい。

しかしうまくいかない。自分は、Python2.5とmatplotlib 0.91.2を使っているのだが。

setup.pyは次のようにした。

from distutils.core import setup
import py2exe
import glob

opts = {
    'py2exe': { "includes" : ["matplotlib.backends", 
                               "matplotlib.figure","pylab", "numpy", "matplotlib.numerix.fft",
                               "matplotlib.numerix.linear_algebra", "matplotlib.numerix.random_array",
                               "matplotlib.backends.backend_tkagg"],
                'excludes': ['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg',
                             '_fltkagg', '_gtk', '_gtkcairo', ],
                'dll_excludes': ['libgdk-win32-2.0-0.dll',
                                 'libgobject-2.0-0.dll']
              }
       }

data_files = [(r'mpl-data', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\*.*')),
                    # Because matplotlibrc does not have an extension, glob does not find it (at least I think that's why)
                    # So add it manually here:
                  (r'mpl-data', [r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']),
                  (r'mpl-data\images',glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\images\*.*')),
                  (r'mpl-data\fonts',glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts\*.*'))]

setup(windows=[{"script": "_main_tree.py"}], options=opts,   data_files=data_files)

で、実行。

> python setup.py py2exe

以下、エラーメッセージ。

Traceback (most recent call last):
  File "setup.py", line 25, in <module>
    setup(windows=[{"script": "_main_tree.py"}], options=opts,   data_files=data_files)
  File "C:\Python25\lib\distutils\core.py", line 151, in setup
    dist.run_commands()
  File "C:\Python25\lib\distutils\dist.py", line 974, in run_commands
    self.run_command(cmd)
  File "C:\Python25\lib\distutils\dist.py", line 994, in run_command
    cmd_obj.run()
  File "C:\Python25\Lib\site-packages\py2exe\build_exe.py", line 223, in run
    self._run()
  File "C:\Python25\Lib\site-packages\py2exe\build_exe.py", line 283, in _run
    dlls = self.find_dlls(extensions)
  File "C:\Python25\Lib\site-packages\py2exe\build_exe.py", line 367, in find_dlls
    self.dll_excludes)
  File "C:\Python25\Lib\site-packages\py2exe\build_exe.py", line 964, in find_dependend_dlls
    bin_depends(loadpath, images + [sys.executable], dll_excludes)
  File "C:\Python25\Lib\site-packages\py2exe\build_exe.py", line 1333, in bin_depends
    if isSystemDLL(dll):
  File "C:\Python25\Lib\site-packages\py2exe\build_exe.py", line 1395, in isSystemDLL
    raise Exception, ("Seems not to be an exe-file", pathname)
Exception: ('Seems not to be an exe-file', 'C:\\WINDOWS\\System32\\WINSOCK.dll')

もうちょっとか。