0

我正在尝试使用 py2exe 创建一个 .exe。

我的应用程序使用envisagetraits打包。

当我使用 python 解释器运行入口点脚本时,一切正常,但是当我生成 .exe 并尝试执行生成的 .exe 文件时,它会给出以下错误:

Traceback (most recent call last):
  File "run_dippo.py", line 14, in <module>
  File "Core\MainApplication.pyc", line 246, in run
  File "envisage\application.pyc", line 292, in start
  File "envisage\application.pyc", line 479, in _create_application_event
  File "traits\trait_types.pyc", line 2695, in validate
  File "traits\trait_types.pyc", line 2793, in resolve_class
  File "traits\trait_types.pyc", line 2526, in resolve_class
  File "traits\trait_types.pyc", line 2555, in validate_failed
  File "traits\trait_handlers.pyc", line 170, in error
traits.trait_errors.TraitError: The 'application' trait of an ApplicationEvent instance must be an envisage.api.IApplication or None, but a value of <Core.MainApplication.MainApplication object at 0x01E5B5D0> <class 'Core.MainApplication.MainApplication'> was specified.

我的 Core.MainApplication.MainApplication 实现如下:

class MainApplication(Application, IApplication):

    Implements(IApplication)

    ...... THE REST OF IT .....

所以我的应用程序实际上是一个 IApplication。

这是我的 setup.py 文件:

from distutils.core import setup
import py2exe

setup(
    name='Aorta',
    version='1.0',
    packages=['Core', 'Core.Interfaces', 'View', 'View.Dialogs', 'View.Widgets',
              'View.CentralPanels', 'Model', 'Model.Pipelines', 'Model.IOSections',     'Model.VisorAdaptors',
              'Model.Visualizations', 'Plugins', 'Plugins.Aorta', 'Plugins.DiPPo', 'Controller', 'Controller.UiLogic',
              'Controller.Commands', 'Controller.Commands.DiPPo', 'Controller.Interfaces'],
    url='',
    license='',
    author='Planetarium',
    author_email='',
    description='',
    windows=[{"script":"run_dippo.py"}],
    options={'py2exe': {"includes": ['sip', 'PyQt4.QtCore','injector','envisage', 'traits'], "bundle_files": 2}},
    zipfile=r'plataforma.zip'
)

有任何想法吗?

4

1 回答 1

0

我更新了我的 setup.py 现在它可以工作了,将“包”更改为:

packages=['Platform.Core',
          'Platform.Core.Interfaces',
          'Platform.View',
          'Platform.View.Dialogs',
          'Platform.View.Widgets'...

一个愚蠢的错误。

于 2013-12-12T15:15:46.400 回答