1
from distutils.core import setup
import py2exe

from distutils.filelist import findall
import os
import matplotlib
matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)
matplotlibdata_files = []
for f in matplotlibdata:
    dirname = os.path.join('matplotlibdata', f[len(matplotlibdatadir)+1:])
    matplotlibdata_files.append((os.path.split(dirname)[0], [f]))


packages = ['matplotlib', 'pytz']
includes = []
excludes = []
dll_excludes = ['libgdk_pixbuf-2.0-0.dll',
                'libgobject-2.0-0.dll',
                'libgdk-win32-2.0-0.dll',
                'wxmsw26uh_vc.dll']


opts = { 'py2exe': { 'packages' : packages,
                     'includes' : includes,
                     'excludes' : excludes,
                     'dll_excludes' : dll_excludes
                    }
         }

setup ( console=['test.py'],
        options = opts,
        data_files = matplotlibdata_files
        )

我通过运行编译应用程序>setup.py py2exe

在编译阶段结束时,它是这样写的:

The following modules appear to be missing

['AppKit', 'FFT', 'Foundation', 'Image', 'LinearAlgebra', 'MA', 'MLab', 'Matrix', 'Numeric', 'PyObjCTools', 'P
yQt4', 'Pyrex', 'Pyrex.Compiler', 'RandomArray', '_curses', '_ssl', 'backends.draw_if_interactive', 'backends.
new_figure_manager', 'backends.pylab_setup', 'backends.show', 'cairo', 'cairo.gtk', 'fcompiler.FCompiler', 'fc
ompiler.show_fcompilers', 'fltk', 'gd', 'gobject', 'gtk', 'lib.add_newdoc', 'matplotlib.enthought.pyface.actio
n', 'mlab.amax', 'mlab.amin', 'numarray', 'numarray.convolve', 'numarray.fft', 'numarray.ieeespecial', 'numarr
ay.linear_algebra', 'numarray.linear_algebra.mlab', 'numarray.ma', 'numarray.numeric', 'numarray.random_array'
, 'numerix.ArrayType', 'numerix.Complex', 'numerix.Complex32', 'numerix.Complex64', 'numerix.Float', 'numerix.
Float32', 'numerix.Float64', 'numerix.Int', 'numerix.Int16', 'numerix.Int32', 'numerix.Int8', 'numerix.NewAxis
', 'numerix.UInt16', 'numerix.UInt32', 'numerix.UInt8', 'numerix.absolute', 'numerix.add', 'numerix.all', 'num
erix.allclose', 'numerix.alltrue', 'numerix.arange', 'numerix.arccos', 'numerix.arccosh', 'numerix.arcsin', 'n
umerix.arcsinh', 'numerix.arctan', 'numerix.arctan2', 'numerix.arctanh', 'numerix.argmax', 'numerix.argmin', '
numerix.argsort', 'numerix.around', 'numerix.array', 'numerix.arrayrange', 'numerix.asarray', 'numerix.asum',
'numerix.bitwise_and', 'numerix.bitwise_or', 'numerix.bitwise_xor', 'numerix.ceil', 'numerix.choose', 'numerix
.clip', 'numerix.compress', 'numerix.concatenate', 'numerix.conjugate', 'numerix.convolve', 'numerix.cos', 'nu
merix.cosh', 'numerix.cross_correlate', 'numerix.cumproduct', 'numerix.cumsum', 'numerix.diagonal', 'numerix.d
ivide', 'numerix.dot', 'numerix.equal', 'numerix.exp', 'numerix.fabs', 'numerix.fft.fft', 'numerix.fft.inverse
_fft', 'numerix.floor', 'numerix.fmod', 'numerix.fromfunction', 'numerix.fromstring', 'numerix.greater', 'nume
rix.greater_equal', 'numerix.hypot', 'numerix.identity', 'numerix.indices', 'numerix.innerproduct', 'numerix.i
scontiguous', 'numerix.less', 'numerix.less_equal', 'numerix.log', 'numerix.log10', 'numerix.logical_and', 'nu
merix.logical_not', 'numerix.logical_or', 'numerix.logical_xor', 'numerix.matrixmultiply', 'numerix.maximum',
'numerix.minimum', 'numerix.mlab.amax', 'numerix.mlab.amin', 'numerix.mlab.cov', 'numerix.mlab.diff', 'numerix
.mlab.hanning', 'numerix.mlab.rand', 'numerix.mlab.std', 'numerix.mlab.svd', 'numerix.multiply', 'numerix.nega
tive', 'numerix.newaxis', 'numerix.nonzero', 'numerix.not_equal', 'numerix.nx', 'numerix.ones', 'numerix.outer
product', 'numerix.pi', 'numerix.power', 'numerix.product', 'numerix.put', 'numerix.putmask', 'numerix.rank',
'numerix.ravel', 'numerix.repeat', 'numerix.reshape', 'numerix.resize', 'numerix.searchsorted', 'numerix.shape
', 'numerix.sin', 'numerix.sinh', 'numerix.size', 'numerix.sometrue', 'numerix.sort', 'numerix.sqrt', 'numerix
.subtract', 'numerix.swapaxes', 'numerix.take', 'numerix.tan', 'numerix.tanh', 'numerix.trace', 'numerix.trans
pose', 'numerix.typecode', 'numerix.typecodes', 'numerix.where', 'numerix.which', 'numerix.zeros', 'numpy.Comp
lex', 'numpy.Complex32', 'numpy.Complex64', 'numpy.Float', 'numpy.Float32', 'numpy.Float64', 'numpy.Infinity',
 'numpy.Int', 'numpy.Int16', 'numpy.Int32', 'numpy.Int8', 'numpy.UInt16', 'numpy.UInt32', 'numpy.UInt8', 'nump
y.inf', 'numpy.infty', 'numpy.oldnumeric', 'objc', 'paint', 'pango', 'pre', 'pyemf', 'qt', 'setuptools', 'setu
ptools.command', 'setuptools.command.egg_info', 'trait_sheet', 'matplotlib.numerix.Float', 'matplotlib.numerix
.Float32', 'matplotlib.numerix.absolute', 'matplotlib.numerix.alltrue', 'matplotlib.numerix.asarray', 'matplot
lib.numerix.ceil', 'matplotlib.numerix.equal', 'matplotlib.numerix.fromstring', 'matplotlib.numerix.indices',
'matplotlib.numerix.put', 'matplotlib.numerix.ravel', 'matplotlib.numerix.sqrt', 'matplotlib.numerix.take', 'm
atplotlib.numerix.transpose', 'matplotlib.numerix.where', 'numpy.core.conjugate', 'numpy.core.equal', 'numpy.c
ore.less', 'numpy.core.less_equal', 'numpy.dft.old', 'numpy.random.rand', 'numpy.random.randn']

1)第一个问题:numpy\core\_internal.pyc not included in Library.zip

No scipy-style subpackage 'core' found in C:\WinCE\Traces\py2exe test\dist\library.zip\numpy. Ignoring: No module named _internal
Traceback (most recent call last):
  File "profiler_ftt.py", line 15, in ?
    from matplotlib.backends.backend_wx import Toolbar, FigureCanvasWx,\
  File "matplotlib\backends\backend_wx.pyc", line 152, in ?
  File "matplotlib\backend_bases.pyc", line 10, in ?
  File "matplotlib\colors.pyc", line 33, in ?
  File "matplotlib\numerix\__init__.pyc", line 67, in ?
  File "numpy\__init__.pyc", line 35, in ?
  File "numpy\_import_tools.pyc", line 173, in __call__
  File "numpy\_import_tools.pyc", line 68, in _init_info_modules
  File "<string>", line 1, in ?
  File "numpy\lib\__init__.pyc", line 5, in ?
  File "numpy\lib\type_check.pyc", line 8, in ?
  File "numpy\core\__init__.pyc", line 6, in ?
  File "numpy\core\umath.pyc", line 12, in ?
  File "numpy\core\umath.pyc", line 10, in __load
AttributeError: 'module' object has no attribute '_ARRAY_API'

我通过将文件添加...\Python24\Lib\site-packages\numpy\core\_internal.pyc...\test\dist\library.zip\numpy\core.
每次编译该可执行文件时,我都会手动添加该文件。
有人知道如何自动添加该文件吗?

2)第二个问题:我不知道如何解决这个问题:

Traceback (most recent call last):
  File "profiler_ftt.py", line 15, in ?
    from matplotlib.backends.backend_wx import Toolbar, FigureCanvasWx,\
  File "matplotlib\backends\backend_wx.pyc", line 152, in ?
  File "matplotlib\backend_bases.pyc", line 10, in ?
  File "matplotlib\colors.pyc", line 33, in ?
  File "matplotlib\numerix\__init__.pyc", line 67, in ?
  File "numpy\__init__.pyc", line 35, in ?
  File "numpy\_import_tools.pyc", line 173, in __call__
  File "numpy\_import_tools.pyc", line 68, in _init_info_modules
  File "<string>", line 1, in ?
  File "numpy\random\__init__.pyc", line 3, in ?
  File "numpy\random\mtrand.pyc", line 12, in ?
  File "numpy\random\mtrand.pyc", line 10, in __load
  File "numpy.pxi", line 32, in mtrand
AttributeError: 'module' object has no attribute 'dtype'

numpy.pxi在文件树和\test\dist\library.zip.
我浏览了网页,希望找到解决方案,但什么也没有。
似乎这个问题是众所周知的,但邮件列表中没有提供解决方案。

4

0 回答 0