First introduce the tools that can be packaged Python code:
- py2exe: This is the most well -known, but it seems that it is not suitable for novice. It requires various libraries. It is tedious to use and not recommended.
-
pyinstaller: It can only generate a separate executable program. The latest version is 3.2.1 Stable, SUPPORTS Python 2.7, 3.3–3.7. You can customize icons. Cross -platform, good compatibility.
-
cx_Freeze :
This packaging quality is very good and the operation is simple. The disadvantage is that it cannot produce separate executable files. As a result, the EXE file is submerged in many files, and it looks not tall. -
The following introduces the specific steps to pack the py file of Tkinter into the EXE file with Pyinstaller:
Method 1:
-
1: Download pyinstaller
-
pip install pyinstaller
After the installation is successful, it will be displayed under the Python/Scripts folder called “Pyinstaller.exe” command file.
2: Put the PY file to be packaged in the Scripts of the Python installation path.
Note that scripts placed various third -party expansion packages of Python, here Pyinstaller.exe is here.
3: Packing EXE program
Step:
-
1. Under the CMD environment into the road path of the SCRIPTS folder;
-
2. Enter instructions Packing: pyinstaller -f **. PY
-
y python3.7.2, win7, pyinstaller3.4 Install the execution of the generated EXE file and open the error. Essence Essence Essence
-
Method 2: You can use the development board Pyinstall to solve the problem. download link:https://github.com/pyinstaller/pyinstaller
-
1. After downloading and decompression, enter this folder through the CMD terminal to execute:
python setup.py install
2. Then the terminal execution (this is performed under the path path of the pyinstall file):
python pyinstaller.py -F F:\python_code_test\rename.py
3. The parameter description in the middle of the common command:
-w instruction: The EXE application with an EXE application with command line debugging windows can be blocked in the instruction. -F instructions: Pay attention to the instructions to distinguish the case. Here is a capital. Using -f instructions can pack the application into an independent EXE file, otherwise it is a folder with various DLL and dependent files