参考:
- https://ask.csdn.net/questions/720080
- https://www.cnblogs.com/gopythoner/p/6337543.html
需打包程序参考: https://www.cnblogs.com/msxh/p/4966899.html
- D:\pythonWorkspace\test>pyinstaller.exe -F -w testa.py
- 74 INFO: PyInstaller: 3.4
- 74 INFO: Python: 3.7.2
- 75 INFO: Platform: Windows-10-10.0.16299-SP0
- 76 INFO: wrote D:\pythonWorkspace\test\testa.spec
- 80 INFO: UPX is not available.
- 82 INFO: Extending PYTHONPATH with paths
- ['D:\\pythonWorkspace\\test', 'D:\\pythonWorkspace\\test']
- 82 INFO: checking Analysis
- 87 INFO: Building because D:\pythonWorkspace\test\testa.py changed
- 87 INFO: Initializing module dependency graph...
- 89 INFO: Initializing module graph hooks...
- 91 INFO: Analyzing base_library.zip ...
- 2803 INFO: running Analysis Analysis-00.toc
- 2806 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
- required by d:\python\python.exe
- 3558 INFO: Caching module hooks...
3563 INFO: Analyzing D:\pythonWorkspace\test\testa.py
- 3788 INFO: Processing pre-find module path hook distutils
- 3820 INFO: Loading module hooks...
- 3820 INFO: Loading module hook "hook-distutils.py"...
- 3823 INFO: Loading module hook "hook-encodings.py"...
- 3908 INFO: Loading module hook "hook-pkg_resources.py"...
- 4162 INFO: Processing pre-safe import module hook win32com
- 4468 INFO: Loading module hook "hook-pydoc.py"...
- 4469 INFO: Loading module hook "hook-pygame.py"...
- 4470 WARNING: Hidden import "pygame._view" not found!
- 4470 INFO: Loading module hook "hook-pythoncom.py"...
- 4711 INFO: Loading module hook "hook-pywintypes.py"...
- 4955 INFO: Loading module hook "hook-sysconfig.py"...
- 4957 INFO: Loading module hook "hook-win32com.py"...
- 5407 INFO: Loading module hook "hook-xml.py"...
- 5630 INFO: Looking for ctypes DLLs
- 5642 INFO: Analyzing run-time hooks ...
- 5645 INFO: Including run-time hook 'pyi_rth_pkgres.py'
- 5648 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
- 5655 INFO: Looking for dynamic libraries
- 7280 INFO: Looking for eggs
- 7281 INFO: Using Python library d:\python\python37.dll
- 7281 INFO: Found binding redirects:
- []
- 7289 INFO: Warnings written to D:\pythonWorkspace\test\build\testa\warn-testa.txt
- 7344 INFO: Graph cross-reference written to D:\pythonWorkspace\test\build\testa\xref-testa.HTML
- 7353 INFO: checking PYZ
- 7356 INFO: Building because toc changed
- 7357 INFO: Building PYZ (ZlibArchive) D:\pythonWorkspace\test\build\testa\PYZ-00.pyz
- 7953 INFO: Building PYZ (ZlibArchive) D:\pythonWorkspace\test\build\testa\PYZ-00.pyz completed successfully.
- 7960 INFO: checking PKG
- 7962 INFO: Building because toc changed
- 7962 INFO: Building PKG (CArchive) PKG-00.pkg
- 11987 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
- 11993 INFO: Bootloader d:\python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
- 11993 INFO: checking EXE
- 11994 INFO: Rebuilding EXE-00.toc because testa.exe missing
- 11995 INFO: Building EXE from EXE-00.toc
- 11998 INFO: Appending archive to EXE D:\pythonWorkspace\test\dist\testa.exe
- 12012 INFO: Building EXE from EXE-00.toc completed successfully.
执行后能在下图路径中的 dist 文件夹内生成一个 exe 应用程序, 我的是 win10 系统, 经实验, 这个应用程序在其他的 win10 电脑中可以运行, 但在 win7 里不行, 若有大神有解决方法, 欢迎指点~
- D:\pythonWorkspace\test>pyinstaller -D -w testa.py
- 71 INFO: PyInstaller: 3.4
- 71 INFO: Python: 3.7.2
- 72 INFO: Platform: Windows-10-10.0.16299-SP0
- 76 INFO: wrote D:\pythonWorkspace\test\testa.spec
- 82 INFO: UPX is not available.
- 84 INFO: Extending PYTHONPATH with paths
- ['D:\\pythonWorkspace\\test', 'D:\\pythonWorkspace\\test']
- 84 INFO: checking Analysis
- 109 INFO: checking PYZ
- 124 INFO: checking PKG
- 124 INFO: Bootloader d:\python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
- 124 INFO: checking EXE
- 124 INFO: Building because console changed
- 124 INFO: Building EXE from EXE-00.toc
- 124 INFO: Appending archive to EXE D:\pythonWorkspace\test\build\testa\testa.exe
- 140 INFO: Building EXE from EXE-00.toc completed successfully.
- 140 INFO: checking COLLECT
- WARNING: The output directory "D:\pythonWorkspace\test\dist\testa" and ALL ITS CONTENTS will be REMOVED! Continue? (y/n)y
- 6765 INFO: Removing dir D:\pythonWorkspace\test\dist\testa
- 6859 INFO: Building COLLECT COLLECT-00.toc
- 7280 INFO: Building COLLECT COLLECT-00.toc completed successfully.
执行后, 可在上图路径中的 dist 文件夹内生成一个 testa 文件夹, 经压缩后就可发给他人电脑中运行了, 我 win10 的系统发到 win7 上可以运行
来源: http://www.bubuko.com/infodetail-2945849.html