Python打包-Pyinstaller,, 我们知道,Pyt
Python打包-Pyinstaller,, 我们知道,Pyt
我们知道,Python很优雅,很值得学习。但是Python是解释性语言,代码需要有Python解释器才能执行,相比较我们平时直接运行exe等可执行文件多了一步的麻烦。
于是,希望能将Python程序打包成exe,使用起来多方便。
PyInstaller可以将Python程序打包成Windows(当然也包括Linux, Mac OS X, Solaris and AIX)下可执行的EXE文件,目前支持python2.7 and 3.3—3.6版本。
官网:http://www.pyinstaller.org/
使用pip命令安装:pip install PyInstaller(会将依赖Pywin32也安装,方便)
安装后看下pyinstaller的版本: pyinstaller --version
下面开始使用pyinstaller打包程序:python2.7+pyinstaller3.3
1、新建py文件: pyInstaller.py
pyInstaller.py1 2 3 45 | #pyinstaller #pipinstallpyinstaller print"HelloPython!"msg = input() |
2、执行打包:pyinstallerpyInstaller.py
常用选项参数:pyinstaller -h 获取详细信息
-F 表示生成单个可执行文件
-w 表示去掉控制台窗口,这在GUI界面时非常有用。不过如果是命令行程序的话那就把这个选项删除吧!
-p 表示你自己自定义需要加载的类路径,一般情况下用不到
-i 表示可执行文件的图标
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | C:\Python27\src>pyinstallerpyInstaller.py 60INFO:PyInstaller:3.3.1 60INFO:Python:2.7.15 60INFO:Platform:Windows-7-6.1.7601-SP1 61INFO:wroteC:\Python27\src\pyInstaller.spec 62INFO:UPXisnotavailable. 65INFO:ExtendingPYTHONPATHwithpaths [‘C:\\Python27\\src‘,‘C:\\Python27\\src‘] 68INFO:checkingAnalysis 68INFO:BuildingAnalysisbecauseout00-Analysis.tocisnonexistent 69INFO:Initializingmoduledependencygraph... 71INFO:Initializingmodulegraphhooks... 156INFO:runningAnalysisout00-Analysis.toc 189INFO:AddingMicrosoft.VC90.CRTtodependentassembliesoffinalexecutable requiredbyc:\python27\python.exe 1780INFO:FoundC:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1 fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest 1782INFO:FoundC:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1 fc8b3b9a1e18e3b_9.0.30729.4940_none_f47ed0f6f6564d90.manifest 1791INFO:FoundC:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1 fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest 1823INFO:Searchingforassemblyx86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30 729.6161_none... 1824INFO:FoundmanifestC:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc 8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57.manifest 1825INFO:Searchingforfilemsvcr90.dll 1825INFO:FoundfileC:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_ 9.0.30729.6161_none_50934f2ebcb7eb57\msvcr90.dll 1825INFO:Searchingforfilemsvcp90.dll 1825INFO:FoundfileC:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_ 9.0.30729.6161_none_50934f2ebcb7eb57\msvcp90.dll 1825INFO:Searchingforfilemsvcm90.dll 1827INFO:FoundfileC:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_ 9.0.30729.6161_none_50934f2ebcb7eb57\msvcm90.dll 1856INFO:FoundC:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1 fc8b3b9a1e18e3b_9.0.30729.1_none_8550c6b5d18a9128.manifest 1857INFO:FoundC:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1 fc8b3b9a1e18e3b_9.0.30729.4940_none_f47ed0f6f6564d90.manifest 1858INFO:FoundC:\Windows\WinSxS\Manifests\x86_policy.9.0.microsoft.vc90.crt_1 fc8b3b9a1e18e3b_9.0.30729.6161_none_f480bfaef65491a5.manifest 1859INFO:AddingredirectMicrosoft.VC90.CRTversion(9,0,21022,8)->(9,0, 30729,6161) 2138INFO:Cachingmodulehooks... 2144INFO:AnalyzingC:\Python27\src\pyInstaller.py 2144INFO:Loadingmodulehooks... 2146INFO:Loadingmodulehook"hook-encodings.py"... 5555INFO:LookingforctypesDLLs 5555INFO:Analyzingrun-timehooks... 5561INFO:Lookingfordynamiclibraries 5680INFO:Lookingforeggs 5682INFO:UsingPythonlibraryC:\Windows\system32\python27.dll 5682INFO:Foundbindingredirects: [BindingRedirect(name=u‘Microsoft.VC90.CRT‘,language=None,arch=u‘x86‘,oldVers ion=(9,0,21022,8),newVersion=(9,0,30729,6161),publicKeyToken=u‘1fc8b3b9a 1e18e3b‘)] 5685INFO:WarningswrittentoC:\Python27\src\build\pyInstaller\warnpyInstaller .txt 5711INFO:Graphcross-referencewrittentoC:\Python27\src\build\pyInstaller\xr ef-pyInstaller.html 5748INFO:checkingPYZ 5748INFO:BuildingPYZbecauseout00-PYZ.tocisnonexistent 5749INFO:BuildingPYZ(ZlibArchive)C:\Python27\src\build\pyInstaller\out00-PY Z.pyz 5993INFO:BuildingPYZ(ZlibArchive)C:\Python27\src\build\pyInstaller\out00-PY Z.pyzcompletedsuccessfully. 6028INFO:checkingPKG 6029INFO:BuildingPKGbecauseout00-PKG.tocisnonexistent 6029INFO:BuildingPKG(CArchive)out00-PKG.pkg 6048INFO:BuildingPKG(CArchive)out00-PKG.pkgcompletedsuccessfully. 6051INFO:Bootloaderc:\python27\lib\site-packages\PyInstaller\bootloader\Windo ws-32bit\run.exe 6051INFO:checkingEXE 6051INFO:BuildingEXEbecauseout00-EXE.tocisnonexistent 6052INFO:BuildingEXEfromout00-EXE.toc 6052INFO:AppendingarchivetoEXEC:\Python27\src\build\pyInstaller\pyInstalle r.exe 6054INFO:BuildingEXEfromout00-EXE.toccompletedsuccessfully. 6060INFO:checkingCOLLECT 6061INFO:BuildingCOLLECTbecauseout00-COLLECT.tocisnonexistent 6063INFO:BuildingCOLLECTout00-COLLECT.toc 6073INFO:RedirectingMicrosoft.VC90.CRTversion(9,0,21022,8)->(9,0,307 29,6161) 6291INFO:RedirectingMicrosoft.VC90.CRTversion(9,0,21022,8)->(9,0,307 29,6161) 6297INFO:UpdatingmanifestinC:\Users\Michael\AppData\Roaming\pyinstaller\bin cache00_py27_32bit\python27.dll 6382INFO:Updatingresourcetype24name2language1033 6572INFO:BuildingCOLLECTout00-COLLECT.toccompletedsuccessfully. |
执行完毕后,会在当前目录的dist中生成pyInstaller.exe
Python打包-Pyinstaller
评论关闭