Introduction to the

Python code certainly requires the Python environment and some external dependency packages to run.

Pyinstaller packages Python scripts into executable programs that run on machines without Python.

The installation

PIP install PyInstallerCopy the code

Packaging operation

Example: Package the following card_main.py file.

It is a console window program. It calls the methods in cards_tools.

Pyinstaller Main program you want to compile.pyCopy the code

Successful operation example:

There are three new files in the directory.

For those of you familiar with Github,

The dist directory typically houses compiled executables.

Just double click to run it.

All you need to do is pack the cards_main file into a zipped package and send it to your friends.

Your friend can simply double click to run the code.

Of course, you can add the -f argument.

pyinstaller -F cards_main.py
Copy the code

The implication is that it is packaged directly into a file. The website address

You just pick and choose according to your needs.

Common error handling

Sometimes the documents we pack up just flash back.

Apparently, there’s something wrong with our program.

Common problems include: The operation related to file reading fails.

We need to copy and paste the file into the dist directory. In order to successfully read the file.

P.S. tips

When we execute the.exe file on the console, the error message is passed to the console to help us Debug.

reference

  1. Official Documentation for PyInstaller

  2. Zhou Xiaodong’s tutorial

The tail language

There may be more to come, but that’s enough for now.

Author: Xia 2 student

Time: 17:35:44, March 26, 2021