编译python3&;pyqt4与cx_冻结
我正在尝试编译一个简单的脚本,我使用Python3和PyQt4编写,使用cx_Freeze,但我有三个问题无法解决编译python3&;pyqt4与cx_冻结,python,windows,python-3.x,pyqt4,cx-freeze,Python,Windows,Python 3.x,Pyqt4,Cx Freeze,我正在尝试编译一个简单的脚本,我使用Python3和PyQt4编写,使用cx_Freeze,但我有三个问题无法解决 我无法显示图标。我正在为它使用一个编译过的资源文件,即导入一个包含资源的.py,我尝试按照建议,将imageformats文件夹复制到我的项目文件夹中,但似乎没有任何效果 我没有使用包括tcl和ttk在内的多个python模块,因此我将它们添加到excludes选项中。然而,它们似乎仍在增加 当我尝试使用base='Win32GUI'编译时,运行创建的exe会引发异常:'NoneT
excludes
选项中。然而,它们似乎仍在增加base='Win32GUI'
编译时,运行创建的exe会引发异常:'NoneType'没有属性“encoding”
from cx_Freeze import setup, Executable
exe = Executable(
script='cconvert.py',
base='Win32GUI'
)
options = dict(
excludes=['curses', 'email', 'tcl', 'ttk']
)
setup(
name="Coord Convertor",
version="0.1",
description="A Coordinate converter from DMS to DD",
requires=['pyqt4 (>=4.8)', 'dtlibs (>=0.4.1)'],
data_files=['imageformats'],
executables=[exe],
options={'build-exe': options}
)
(请注意约1。)
2:在options={'build-exe'…,我认为它应该是build_-exe(下划线而不是破折号)
3:您是否正在尝试访问类似于
sys.stdout.encoding
anywhere的内容?sys.stdout
在使用Win32 GUI基础时将不存在。即使是print()
调用可能会触发此问题。已解决。除了Thomas的指针之外,我还需要将“imageformats”置于选项中的“include files”下,而不是“data_files”。我的最终脚本如下所示:
from cx_Freeze import setup, Executable
exe = Executable(
script='cconvert.pyw',
base='Win32GUI'
)
options = dict(
excludes=['curses', 'email', 'tcl', 'ttk', 'tkinter'],
include_files=['imageformats']
)
setup(
name="Coord Convertor",
version="0.1",
description="A Coordinate converter from DMS to DD",
requires=['pyqt4 (>=4.8)', 'dtlibs (>=0.4.1)'],
executables=[exe],
options={'build_exe': options}
)
新文档已在Readthedocs上-请务必来帮助我们改进它:谢谢-我实际上刚刚找到它。不幸的是,它似乎也不能解决我的问题。如果我解决了它们,我会添加到文档中。Grr…愚蠢的打字错误。这是2。修复了。你已经解决了3,谢谢。每次开始时我都在运行doctest,打印到std我发现在其他计算机上显示图标也需要QtSvg。确保这一点的最简单方法是将PyQt4.QtSvg导入代码中的某个位置。