【问题标题】:Error converting GUI to standalone executable using Py2exe使用 Py2exe 将 GUI 转换为独立可执行文件时出错
【发布时间】:2016-11-21 12:06:21
【问题描述】:

我正在使用py2exe 将具有多个 GUI 的程序转换为独立的可执行文件。我使用 PyQt 创建 GUI。我运行的主脚本实例化了主 UI,其中包含可以打开子 UI 的按钮、选项卡等。主脚本是main_ui.py

我遵循了如何使用py2exe的教程,所以我有以下setup.py

from distutils.core import setup
import py2exe

setup(windows=['main_ui.py'])

然后,在 CMD 中:> python setup.py py2exe

我尝试用一​​个简单的脚本创建一个练习 exe,一切正常。但是,当我尝试从 main_ui.py 创建 exe 时出现错误。

这是输出:

L:\internal\(path)>python setup.py py2exe
running py2exe
creating L:\internal\(path)\build
creating L:\internal\(path)\build\bdist.win32
creating L:\internal\(path)\build\bdist.win32\winexe
creating L:\internal\(path)\build\bdist.win32\winexe\collect-2.7
creating L:\internal\(path)\build\bdist.win32\winexe\bundle-2.7
creating L:\internal\(path)\build\bdist.win32\winexe\temp
creating L:\internal\(path)\dist
*** searching for required modules ***
error: compiling 'C:\Python27\lib\site-packages\PyQt4\uic\port_v3\proxy_base.py' failed
SyntaxError: invalid syntax <proxy_base.py, line 26>

这里是proxy_base.py

from PyQt4.uic.Compiler.proxy_metaclass import ProxyMetaclass


class ProxyBase(metaclass=ProxyMetaclass):
""" A base class for proxies using Python v3 syntax for setting the
meta-class.
"""

这是 PyQt4 自带的;有谁知道发生了什么?这是将我的程序变成可执行文件的正确方法吗?

【问题讨论】:

    标签: python user-interface pyqt4 executable py2exe


    【解决方案1】:

    我也遇到了同样的问题。很可能有更好的方法,但删除文件夹“PyQt4\uic\port_v3”可以解决问题。

    (见http://python.6.x6.nabble.com/PyQt-4-7-and-py2exe-error-td1922933.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-16
      • 1970-01-01
      • 2018-04-07
      • 1970-01-01
      相关资源
      最近更新 更多