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 模式