从这里安装cx_Freeze
解压缩文件夹并从该目录运行以下命令:
pythonsetup.pybuild sudo pythonsetup.pyinstall
为您的python脚本创建一个新目录,并在同一目录中创建一个具有以下内容的“ setup.py”文件:
application_title = "My Application" # 使用您自己的应用程序名称 main_python_file = "my_script.py" # 您的python脚本 import sys from cx_Freeze import setup, Executable base = None ifsys.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从终端运行:
pythonsetup.pybdist_mac
注意:在El Capitan上,这将需要以root身份运行且禁用SIP模式。