如何从Python程序中创建EXE文件?(复制)

时间:2022-02-19 20:48:25

This question already has an answer here:

这个问题已经有了答案:

I've used several modules to make EXEs for Python, but I'm not sure if I'm doing it right.

我使用了几个模块来为Python做EXEs,但我不确定我是否做对了。

How should I go about this, and why? Please base your answers on personal experience, and provide references where necessary.

我该怎么做,为什么?请根据个人经验回答,必要时提供参考。

7 个解决方案

#1


76  

py2exe is probably what you want, but it only works on Windows.
PyInstaller works on Windows and Linux.
Py2app works on the Mac.

py2exe可能是您想要的,但它只适用于Windows。PyInstaller在Windows和Linux上运行。Py2app在Mac上运行。

#2


10  

I found this presentation to be very helpfull.

我觉得这个报告很有帮助。

How I Distribute Python applications on Windows - py2exe & InnoSetup

如何在Windows - py2exe和InnoSetup上分发Python应用程序

From the site:

从这个网站:

There are many deployment options for Python code. I'll share what has worked well for me on Windows, packaging command line tools and services using py2exe and InnoSetup. I'll demonstrate a simple build script which creates windows binaries and an InnoSetup installer in one step. In addition, I'll go over common errors which come up when using py2exe and hints on troubleshooting them. This is a short talk, so there will be a follow-up Open Space session to share experience and help each other solve distribution problems.

Python代码有许多部署选项。我将分享在Windows、使用py2exe和InnoSetup打包命令行工具和服务时所做的工作。我将演示一个简单的构建脚本,它将在一个步骤中创建windows二进制文件和一个InnoSetup安装程序。此外,我还将介绍在使用py2exe时出现的常见错误,以及对它们进行故障排除的提示。这是一个简短的谈话,所以将会有一个后续的开放空间会议来分享经验和帮助彼此解决分配问题。

#3


4  

Also known as Frozen Binaries but not the same as as the output of a true compiler- they run byte code through a virtual machine (PVM). Run the same as a compiled program just larger because the program is being compiled along with the PVM. Py2exe can freeze standalone programs that use the tkinter, PMW, wxPython, and PyGTK GUI libraties; programs that use the pygame game programming toolkit; win32com client programs; and more. The Stackless Python system is a standard CPython implementation variant that does not save state on the C language call stack. This makes Python more easy to port to small stack architectures, provides efficient multiprocessing options, and fosters novel programming structures such as coroutines. Other systems of study that are working on future development: Pyrex is working on the Cython system, the Parrot project, the PyPy is working on replacing the PVM altogether, and of course the founder of Python is working with Google to get Python to run 5 times faster than C with the Unladen Swallow project. In short, py2exe is the easiest and Cython is more efficient for now until these projects improve the Python Virtual Machine (PVM) for standalone files.

也称为冻结二进制文件,但与真正的编译器的输出不一样——它们通过虚拟机(PVM)运行字节码。运行与已编译程序相同的程序,只是因为程序与PVM一起被编译。Py2exe可以冻结使用tkinter、PMW、wxPython和PyGTK GUI库的独立程序;使用pygame编程工具包的程序;win32com客户项目;和更多。Stackless Python系统是一个标准的CPython实现变体,它不会在C语言调用堆栈上保存状态。这使得Python更容易移植到小型堆栈架构,提供高效的多处理选项,并促进新的编程结构,如coroutines。其他系统的研究工作在未来发展:Pyrex正在Cython系统,鹦鹉项目,PyPy正在取代PVM,当然Python正在与谷歌的创始人让Python运行5倍C Unladen Swallow项目。简而言之,py2exe是最简单的,而Cython现在更有效,直到这些项目改进了独立文件的Python虚拟机(PVM)。

#4


3  

Not on the freehackers list is gui2exe which can be used to build standalone Windows executables, Linux applications and Mac OS application bundles and plugins starting from Python scripts.

在freehackers列表中没有gui2exe,它可以用于构建独立的Windows可执行程序、Linux应用程序和Mac OS应用程序包以及从Python脚本开始的插件。

#5


2  

See a short list of python packaging tools on FreeHackers.org.

请参阅FreeHackers.org上的python打包工具的简短列表。

#6


2  

Use cx_Freeze to make exe your python program

使用cx_Freeze使exe成为您的python程序

#7


2  

py2exe:

py2exe:

py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.

py2exe是一个Python Distutils扩展,它将Python脚本转换为可执行的Windows程序,可以在不需要Python安装的情况下运行。

#1


76  

py2exe is probably what you want, but it only works on Windows.
PyInstaller works on Windows and Linux.
Py2app works on the Mac.

py2exe可能是您想要的,但它只适用于Windows。PyInstaller在Windows和Linux上运行。Py2app在Mac上运行。

#2


10  

I found this presentation to be very helpfull.

我觉得这个报告很有帮助。

How I Distribute Python applications on Windows - py2exe & InnoSetup

如何在Windows - py2exe和InnoSetup上分发Python应用程序

From the site:

从这个网站:

There are many deployment options for Python code. I'll share what has worked well for me on Windows, packaging command line tools and services using py2exe and InnoSetup. I'll demonstrate a simple build script which creates windows binaries and an InnoSetup installer in one step. In addition, I'll go over common errors which come up when using py2exe and hints on troubleshooting them. This is a short talk, so there will be a follow-up Open Space session to share experience and help each other solve distribution problems.

Python代码有许多部署选项。我将分享在Windows、使用py2exe和InnoSetup打包命令行工具和服务时所做的工作。我将演示一个简单的构建脚本,它将在一个步骤中创建windows二进制文件和一个InnoSetup安装程序。此外,我还将介绍在使用py2exe时出现的常见错误,以及对它们进行故障排除的提示。这是一个简短的谈话,所以将会有一个后续的开放空间会议来分享经验和帮助彼此解决分配问题。

#3


4  

Also known as Frozen Binaries but not the same as as the output of a true compiler- they run byte code through a virtual machine (PVM). Run the same as a compiled program just larger because the program is being compiled along with the PVM. Py2exe can freeze standalone programs that use the tkinter, PMW, wxPython, and PyGTK GUI libraties; programs that use the pygame game programming toolkit; win32com client programs; and more. The Stackless Python system is a standard CPython implementation variant that does not save state on the C language call stack. This makes Python more easy to port to small stack architectures, provides efficient multiprocessing options, and fosters novel programming structures such as coroutines. Other systems of study that are working on future development: Pyrex is working on the Cython system, the Parrot project, the PyPy is working on replacing the PVM altogether, and of course the founder of Python is working with Google to get Python to run 5 times faster than C with the Unladen Swallow project. In short, py2exe is the easiest and Cython is more efficient for now until these projects improve the Python Virtual Machine (PVM) for standalone files.

也称为冻结二进制文件,但与真正的编译器的输出不一样——它们通过虚拟机(PVM)运行字节码。运行与已编译程序相同的程序,只是因为程序与PVM一起被编译。Py2exe可以冻结使用tkinter、PMW、wxPython和PyGTK GUI库的独立程序;使用pygame编程工具包的程序;win32com客户项目;和更多。Stackless Python系统是一个标准的CPython实现变体,它不会在C语言调用堆栈上保存状态。这使得Python更容易移植到小型堆栈架构,提供高效的多处理选项,并促进新的编程结构,如coroutines。其他系统的研究工作在未来发展:Pyrex正在Cython系统,鹦鹉项目,PyPy正在取代PVM,当然Python正在与谷歌的创始人让Python运行5倍C Unladen Swallow项目。简而言之,py2exe是最简单的,而Cython现在更有效,直到这些项目改进了独立文件的Python虚拟机(PVM)。

#4


3  

Not on the freehackers list is gui2exe which can be used to build standalone Windows executables, Linux applications and Mac OS application bundles and plugins starting from Python scripts.

在freehackers列表中没有gui2exe,它可以用于构建独立的Windows可执行程序、Linux应用程序和Mac OS应用程序包以及从Python脚本开始的插件。

#5


2  

See a short list of python packaging tools on FreeHackers.org.

请参阅FreeHackers.org上的python打包工具的简短列表。

#6


2  

Use cx_Freeze to make exe your python program

使用cx_Freeze使exe成为您的python程序

#7


2  

py2exe:

py2exe:

py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.

py2exe是一个Python Distutils扩展,它将Python脚本转换为可执行的Windows程序,可以在不需要Python安装的情况下运行。