[英]Problems compiling python3 & pyqt4 with cx_freeze
我正在尝试使用cx_Freeze编译一个我使用Python3和PyQt4编写的简单脚本,但我有三个问题,我无法弄清楚。
我无法显示图标。 我正在使用一个已编译的资源文件,即导入包含资源的.py,我试图按照这里的建议,将imageformats文件夹复制到我的项目文件夹,但似乎没有任何工作。
我没有使用包含tcl和ttk的severl python模块,所以我将它们添加到了excludes
选项中。 但是,它们似乎仍然被添加。
当我尝试使用base='Win32GUI'
进行编译时,运行创建的exe会引发异常: 'NoneType' has no attribute 'encoding'
我很确定我的安装脚本有问题,因为cx_Freeze文档不是很冗长,所以希望有人可以指出问题所在。 这是设置脚本。 我不会发布我正在编译的脚本,因为它很长,但如果它需要我将尝试创建一个简洁的版本进行测试。
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}
)
解决了。 除了托马斯的指针之外,我还需要'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}
)
(请注意1)
2:在options = {'build-exe'...中,我认为它需要是build_exe(下划线而不是破折号)。
3:您是否尝试在任何地方访问sys.stdout.encoding
? 使用Win32GUI库时, sys.stdout
将为None。 即使是print()
调用也可能触发它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.