将python脚本打包为exe可执行文件

[En]

In many cases, programmers complete programming tasks in the Linux environment, but more users are in the Windows environment, for example, mentioned in the article referring to link 1:

[En]

Then we have to consider the problem of environmental transformation. As a general programming language, python itself can run in different environments, but executable files are not. For now, the easiest way is to compile executables with pyinstaller on their respective platforms.

[En]

When we compile an executable file, we first need an executable python task script, which can be a series of complex operations, either displaying a picture or a complete PC-side software. One of the tasks we wrote here is to create a discrete sine function image with numpy and then display it using matplotlib:

[En]

It is important to note that if you create a python script that depends on some printout functions, you need to specify a pop-up terminal window when compiling the executable, otherwise the program will not execute correctly.

pyinstaller也是一个跨平台的python工具，在windows和linux上面都可以使用pip来进行安装和管理：

[En]

As you can see, although there is a slight difference in visual effect with the running result of the executable file under linux, it is basically the same.

[En]

After completing the implementation of a software or program, the last step is to release, the purpose of release is to allow more people to use the project, and most people do not have the corresponding programming environment, so we must consider compiling the code into executable files for each platform and then releasing it to users. This article mainly introduces how to package python scripts into executable files on linux and windows through pyinstaller. At present, it is difficult to implement cross-platform compiling software. Bloggers use Win11+WSL2 Ubuntu Linux environment locally, which can solve the problem of cross-platform publishing to a certain extent.

Original: https://www.cnblogs.com/webenh/p/16171371.html
Author: WebEnh
Title: 将python脚本打包为exe可执行文件

(0)