一 点睛
Python项目打包需要安装PyInstaller模块。
二 打包
1 CMD命令进入命令行
2 在命令行执行如下语句:
pyinstaller -F E:\Python\studentsystem\studentsystem.py
其中-F 表示只生成一个扩展名为.exe的可执行文件。
执行结果如下:
(venv) E:\Python\studentsystem>pyinstaller -F E:\Python\studentsystem\studentsystem.py
354 INFO: PyInstaller: 3.4
354 INFO: Python: 3.6.7
355 INFO: Platform: Windows-10-10.0.17134-SP0
356 INFO: wrote E:\Python\studentsystem\studentsystem.spec
366 INFO: UPX is not available.
370 INFO: Extending PYTHONPATH with paths
['E:\\Python\\studentsystem', 'E:\\Python\\studentsystem']
371 INFO: checking Analysis
371 INFO: Building Analysis because Analysis-00.toc is non existent
371 INFO: Initializing module dependency graph...
374 INFO: Initializing module graph hooks...
376 INFO: Analyzing base_library.zip ...
3833 INFO: running Analysis Analysis-00.toc
3894 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by E:\Python\studentsystem\venv\Scripts\python.exe
4603 INFO: Caching module hooks...
4610 INFO: Analyzing E:\Python\studentsystem\studentsystem.py
4650 INFO: Loading module hooks...
4650 INFO: Loading module hook "hook-encodings.py"...
4794 INFO: Loading module hook "hook-pydoc.py"...
4797 INFO: Loading module hook "hook-xml.py"...
5039 INFO: Looking for ctypes DLLs
5039 INFO: Analyzing run-time hooks ...
5043 INFO: Looking for dynamic libraries
5260 INFO: Looking for eggs
5260 INFO: Using Python library E:\Python\studentsystem\venv\Scripts\python36.dll
5261 INFO: Found binding redirects:
[]
5265 INFO: Warnings written to E:\Python\studentsystem\build\studentsystem\warn-studentsystem.txt
5298 INFO: Graph cross-reference written to E:\Python\studentsystem\build\studentsystem\xref-studentsystem.html
5317 INFO: checking PYZ
5318 INFO: Building PYZ because PYZ-00.toc is non existent
5318 INFO: Building PYZ (ZlibArchive) E:\Python\studentsystem\build\studentsystem\PYZ-00.pyz
5718 INFO: Building PYZ (ZlibArchive) E:\Python\studentsystem\build\studentsystem\PYZ-00.pyz completed successfully.
5722 INFO: checking PKG
5723 INFO: Building PKG because PKG-00.toc is non existent
5723 INFO: Building PKG (CArchive) PKG-00.pkg
7957 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
7965 INFO: Bootloader E:\Python\studentsystem\venv\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
7967 INFO: checking EXE
7967 INFO: Building EXE because EXE-00.toc is non existent
7968 INFO: Building EXE from EXE-00.toc
7969 INFO: Appending archive to EXE E:\Python\studentsystem\dist\studentsystem.exe
8000 INFO: Building EXE from EXE-00.toc completed successfully.
三 验证