我已经指出了将 pygame 导出到可执行文件以进行分发的问题。我仍然有一个问题,当我运行 setup.py (我使用 python 版本 3.7.0)并构建应用程序时,应用程序直接崩溃,我也无法打开 unix 可执行文件。
这正是我到目前为止所做的:
我的设置.py:
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need
# fine tuning.
build_exe_options = {"include_files" : ["pic.png", "sound.wav"]} # there are more files, i.e. all pics and audio files used
import sys
base = 'Win32GUI' if sys.platform=='win32' else None
executables = [
Executable('pythonGame.py', base=base)
]
setup(name='MyGame',
version = '1.0',
description = 'blabla',
options = dict(build_exe = build_exe_options),
executables = executables)
当我运行 setup.py 通过以下方式创建独立应用程序时:
python setup.py bdist_mac
我收到(许多)错误消息(参见最后 3 行终端输出):
> error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool:
> input file:
> build/GesaGame-1.0.app/Contents/MacOS/lib/pygame/pygame_icon.icns is
> not a Mach-O file @loader_path/.dylibs/libSDL-1.2.0.dylib error: can't
> copy '@loader_path/.dylibs/libSDL-1.2.0.dylib': doesn't exist or not a
> regular file
或以上
> error: /Library/Developer/CommandLineTools/usr/bin/install_name_tool:
> input file: build/GesaGame-1.0.app/Contents/MacOS/RunningCleats.wav is
> not a Mach-O file
尽管如此,构建文件夹已经创建。打开时找到指定的程序,但启动后直接崩溃。
我在这里做错了什么?我怀疑这与包含的文件有关,但我无法理解它。