Package the.py file into an exe, go directly to CMD and run pyInstaller -f setup.py, as shown below.

The ps: -f parameter means to overpack, so that when we pack, no matter how many times we pack, it’s up to date. Just remember that. Fixed command.

2. After the execution, several folders will be generated, as shown below.

3. In DIST, there is an EXE program, which is the executable exe program, as shown in the figure below.

4. Drag setup.exe to the same level as setup.py and run it as shown below.

5. Thus, we have a package that can run without a Python environment if someone else needs it.

6, next we will package a with the interface, here I use PyQt5 to write a simple framework, see if the package as exe can run successfully, the effect picture is shown below.

As we can see, there’s a dark window in the back, which is a little awkward, so our packing order has to change as well.

Pyinstaller -f-wsetup. py with -w will not display a black console.

But we package the EXE, our icon ah, it is a little ugly, the default, no own style, so, how should we change it?

Run the pyinstaller -f -w -I wind.ico setup.py command, as shown in the following figure.

9, the default package picture, as shown below.

10. After adding the -i parameter, as shown in the picture below, a logo pattern similar to that of a wind turbine will be formed.

Ps: the program path had better be all in English, otherwise it may appear puzzling problems

11, at this point, we can use pyton package into exe commands are summed up

Conclusion the command

Pyinstaller -f setup.py packages exe

Pyinstaller -f -w setup.py is packaged without a console

Pyinstaller -f -i xx.ico setup.py Package Specifies the package of exe ICONS

Normally, we only need these three, which is enough for all our needs.

Citation:

Stop asking me how to package Python into exe!

zhuanlan.zhihu.com