我正在使用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)buildbdist.win32
creating L:internal(path)buildbdist.win32winexe
creating L:internal(path)buildbdist.win32winexecollect-2.7
creating L:internal(path)buildbdist.win32winexebundle-2.7
creating L:internal(path)buildbdist.win32winexetemp
creating L:internal(path)dist
*** searching for required modules ***
error: compiling 'C:Python27libsite-packagesPyQt4uicport_v3proxy_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;有人知道发生了什么事吗?这是把我的程序变成可执行程序的正确方法吗?
我也遇到了同样的问题。可能有更好的方法,但删除文件夹"PyQt4\uic\port_v3"可以解决这个问题。
(参见http://python.6.x6.nabble.com/PyQt-4-7-and-py2exe-error-td1922933.html)