cx 冻结

这里安装 cx_Freeze

解压缩文件夹并从该目录运行以下命令:

python setup.py build
sudo python setup.py install

为 python 脚本创建一个新目录,并在同一目录中创建一个 “setup.py” 文件,其中包含以下内容:

application_title = "My Application" # Use your own application name
main_python_file = "my_script.py" # Your python script

import sys

from cx_Freeze import setup, Executable

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

includes = ["atexit","re"]

setup(
        name = application_title,
        version = "0.1",
        description = "Your Description",
        options = {"build_exe" : {"includes" : includes }},
        executables = [Executable(main_python_file, base = base)])

现在从终端运行你的 setup.py:

python setup.py bdist_mac

注意:在 El Capitan 上,需要以 root 身份运行,禁用 SIP 模式