gpt4 book ai didi

python - py2exe python 应用程序在 pyside 中使用 Chaco 时出错

转载 作者:行者123 更新时间:2023-11-30 23:37:26 26 4
gpt4 key购买 nike

在此处输入代码我有一个程序,该程序使用嵌入在 pyside (Qt4) GUI 中的 Enthought Chaco 图。它还使用 numpy,但没关系。该程序直接从 Python 在多个平台上运行良好,但是当我使用 py2exe 创建 win32 的 .exe 时,运行 .exe 时出现错误:

Traceback (most recent call last):
File "awesome_program.pyw", line 19, in <module>
File "plotwidget.pyc", line 13, in <module>
File "enable\api.pyc", line 8, in <module>
File "enable\base.pyc", line 35, in <module>
File "enable\colors.pyc", line 246, in <module>
File "traitsui\qt4\color_editor.pyc", line 21, in <module>
File "traitsui\editors\__init__.pyc", line 22, in <module>
File "traitsui\editors\api.pyc", line 29, in <module>
File "traitsui\editors\list_str_editor.pyc", line 33, in <module>
File "pyface\image_resource.pyc", line 18, in <module>
File "pyface\toolkit.pyc", line 73, in <module>
File "pyface\toolkit.pyc", line 38, in _init_toolkit
File "pyface\toolkit.pyc", line 31, in import_toolkit
ImportError: No module named init

setup.py 文件是:

#! /usr/bin/env python
# setup_win32.py

# Create an .exe for win32 systems.
# Run this with:
# python setup_win32.py py2exe

import sys
from distutils.core import setup
import py2exe
# from cx_Freeze import setup, Executable

includes = []
includes.append("PySide.QtUiTools")
includes.append("PySide.QtXml")

base = None
if sys.platform == "win32":
base = "Win32GUI"

setup(options = {"py2exe": {"dll_excludes":["MSVCP90.dll"],
"includes": includes}},
name='awesomeprogram',
version='0.01',
description='A program to visualize stuff.',
author='John Doe',
author_email='dude@email.com',
console=[{"script": "awesome_program.pyw"}])

我对 Chaco 和 py2exe 相当陌生,但我感觉需要在我的 py2exe 安装文件中明确包含 Enthought 套件中的某些内容?有人有这方面的经验吗?

最佳答案

我没有使用过 py2exe,但我对 py2app 有一些经验(我认为这是相似的)。它无法包含许多 Enthought/chaco 包,因此您需要在 setup.py 中手动包含它们。这是我所做的:

OPTIONS = dict(
includes = [
# The backends are dynamically imported and thus we need to
# tell py2app about them.
'kiva.*',
'enable.*',
'enable.qt4.*',
'pyface.*',
'pyface.ui.qt4.*',
'pyface.ui.qt4.action.*',
'pyface.ui.qt4.timer.*',
'pyface.ui.qt4.wizard.*',
'pyface.ui.qt4.workbench.*',
'traitsui.qt4.*',
'traitsui.qt4.extra.*',
'PyQt4.pyqtconfig',
'glob.*'],
argv_emulation = True)

setup(
app=APP,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)

如果您替换使用类似的选项(当然将py2app替换为py2exe,并且可能将PyQt4替换为PySide >),它可能对你有用。如果再次导入失败,只需将其添加到包含列表中即可。

关于python - py2exe python 应用程序在 pyside 中使用 Chaco 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15561722/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com