python - 如何在 Mac 上使用 cx_Freeze?

标签 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周了,谢谢。

最佳答案

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

关于python - 如何在 Mac 上使用 cx_Freeze?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31104990/

相关文章:

linux - 使用bash脚本打开多个终端窗口mac

python - "TypeError: unhashable type: ' slice'"是什么意思?我该如何修复它?

python - 在 or-tools python 中向调度问题添加软约束

Python - 我应该使用只读 @property 而不使用 init 或 setter 吗?

macos - 在 macOS 上的 python 2.7 上安装 rpy2

python - 将 os.path.join 与 os.path.getsize 一起使用,返回 FileNotFoundError

python - 解析时出现意外的 EOF

python - Django 从模型变量渲染模板

python - Django/Python 中的自动增量字段

objective-c - 用于拦截另一个应用程序中的文本输入的 API?