如何在mac上使用cx_Freeze?

时间:2015-06-28 21:34:14

标签: python macos python-3.4 cx-freeze

我在我的mac上使用了python 3.4和cx_Freeze。我试图将我的python脚本转换为独立的应用程序,这是我在setup.py文件中获得的代码:

application_title = "Death Dodger 1.0" 
main_python_file = "DeathDodger-1.0.py"

import sys

from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
base = "Win32GUI"

includes = ["atexit","re"]

setup(
        name = application_title,
        version = "1.0",
        description = "Sample cx_Freeze script",
        options = {"build_exe" : {"includes" : includes }},
        executables = [Executable(main_python_file, base = base)])

我在这些代码行中输入了我的终端:

cd /Users/HarryHarlow/Desktop/Death_Dodger

我输入以下行:

python3.4 setup.py bdist_mac

在排除其他结果后,我收到了此错误消息:

error: [Errno 2] No such file or directory:       '/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl'

请帮助,我已经坚持了 3周,谢谢。

1 个答案:

答案 0 :(得分:2)

如果您不需要Tcl,可以在设置文件中将其排除在外:

application_title = "Death Dodger 1.0" 
main_python_file = "DeathDodger-1.0.py"

import sys

from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
    base = "Win32GUI"

includes = ["atexit","re"]

setup(
    name = application_title,
    version = "1.0",
    description = "Sample cx_Freeze PyQt4 script",
    options = {
        "build_exe" : {
            "includes" : includes
            "excludes": ['tcl', 'ttk', 'tkinter', 'Tkinter'], 
        }
    },
    executables = [
        Executable(main_python_file, base = base)
    ]
)

我也排除了Tkinter,因为据我所知,你正在利用PyQt4来绘制用户界面。