【问题标题】:How do I use cx_Freeze on mac?如何在 Mac 上使用 cx_Freeze?
【发布时间】:2015-06-28 21:34:13
【问题描述】:

我在我的 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 周,谢谢。

【问题讨论】:

    标签: python macos python-3.4 cx-freeze


    【解决方案1】:

    如果你不需要 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 来绘制用户界面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-11
      • 1970-01-01
      • 1970-01-01
      • 2015-06-25
      • 2021-08-16
      • 2014-05-02
      相关资源
      最近更新 更多