使用 pyinstaller 将 python 程序转换为 windows 中的可执行文件的工作过程

Working process of converting python programs to executables in windows using pyinstaller

我想将我的 python 项目之一转换为 windows 的可执行文件或某些应用程序,这样它们就可以在不进入 python 界面和 运行 界面的情况下运行从那里。快速搜索发现 pyinstaller 的存在,我使用了它。当我在其官方网站上阅读它的工作时,那里有以下声明:"The PyInstaller bootloader is a binary executable program for the active platform (Windows, Linux, Mac OS X, etc.). When the user launches your program, it is the bootloader that runs. The bootloader creates a temporary Python environment such that the Python interpreter will find all imported modules and libraries in the myscript folder."

现在我想知道的是,如果生成的 .exe 文件在其他系统上使用,是否有必要安装 pyinstaller 以便激活引导加载程序?还有必要拥有所有必需的 python 模块和库,以便引导加载程序可以创建临时环境吗?我们可以更改给定的界面吗?还有哪些其他方法可以将 .py 文件更改为 .exe?

Pyinstaller 会将 Python 文件和所有必需的 libraries/modules 编译成 exe 文件。然后,您可以 运行 在另一台计算机上安装它,而无需安装任何其他程序。

当用户启动您的程序时,运行是引导加载程序。引导加载程序创建一个临时 Python 环境,这样 Python 解释器将在 myscript 文件夹中找到所有导入的模块和库。 这意味着当您 运行 可执行文件时,命令样式 window 将启动,其中 python 代码将 运行。此 window 还将显示所有错误消息、打印语句等。