作了一個生成二維碼的小程序:http://www.cnblogs.com/dcb3688/p/4241048.htmlhtml
直接運行腳本沒問題,用pyinstaller打包後再運行就直接報錯了:bootstrap
應用程序沒法啓動 由於程序的並行配置不正確。有關詳細信息,請參閱應用程序事件日誌,或使用命令行 sxstrace.exe 工具。小程序
網上找的解決方法:工具
1. 安裝Microsoft Visual C++ 2008 Redistributableui 2. 開始 - 運行(輸入services.msc)- 肯定或回車,打開:服務(本地),開啓Windows Modules Installer服務spa
|
第一種,我電腦已經安裝VC2008,且VC2005 和VC2010 都安裝了, 排除!命令行
第二種,打開本地服務,發現Windows Modules Installer 已是開啓的, 排除!debug
因此仍是在打包的信息中尋找線索吧調試
找打包時的信息分析後發現:日誌
1 19753 INFO: Looking for run-time hooks 2 19754 INFO: Analyzing rthook C:\Python27\lib\site-packages\pyinstaller-2.1.1.dev0-py2.7.egg\PyInstaller\loader\rthooks\pyi_rth_qt4plugins.py 3 19845 INFO: Analyzing rthook C:\Python27\lib\site-packages\pyinstaller-2.1.1.dev0-py2.7.egg\PyInstaller\loader\rthooks\pyi_rth_PIL_Image.py 4 19954 INFO: Analyzing rthook C:\Python27\lib\site-packages\pyinstaller-2.1.1.dev0-py2.7.egg\PyInstaller\loader\rthooks\pyi_rth_Image.py 5 22815 INFO: Adding Microsoft.VC90.DebugCRT to dependent assemblies of final executable 6 22894 INFO: Searching for assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ... 7 22894 WARNING: Assembly not found 8 22894 ERROR: Assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found 9 23014 INFO: Searching for assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
是缺乏VC90.CRT,但在系統中是能夠找的到的:
1 608 INFO: wrote E:\www\pyqt\TEST\qrcode_a.spec 2 684 INFO: Testing for ability to set icons, version resources... 3 888 INFO: ... resource update available 4 892 INFO: UPX is not available. 5 1000 INFO: Processing hook hook-os 6 1273 INFO: Processing hook hook-time 7 1279 INFO: Processing hook hook-cPickle 8 1434 INFO: Processing hook hook-_sre 9 1914 INFO: Processing hook hook-cStringIO 10 2136 INFO: Processing hook hook-encodings 11 2161 INFO: Processing hook hook-codecs 12 4158 INFO: Extending PYTHONPATH with E:\www\pyqt\TEST 13 4161 INFO: checking Analysis 14 4161 INFO: Building Analysis because out00-Analysis.toc non existent 15 4161 INFO: running Analysis out00-Analysis.toc 16 4162 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable 17 11481 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ... 18 11485 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest 19 11508 INFO: Searching for file msvcr90.dll 20 11509 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll 21 11510 INFO: Searching for file msvcp90.dll 22 11511 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcp90.dll 23 11513 INFO: Searching for file msvcm90.dll 24 11513 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcm90.dll 25 11827 INFO: Analyzing C:\Python27\lib\site-packages\pyinstaller-2.1.1.dev0-py2.7.egg\PyInstaller\loader\_pyi_bootstrap.py
忽然發現程序找的依賴DLL不是x86_microsoft.vc90.CRT 而是 x86_Microsoft.VC90.DebugCRT , 應該是debug調試模式運行
網上找來找去也沒有找到x86_Microsoft.VC90.DebugCRT.dll 的下載地址
在看看Pyinstaller裏面的參數說明:
----------------------------------------------------------------------------------------------------------
-F, --onefile Py代碼只有一個文件
-D, --onedir Py代碼放在一個目錄中(默認是這個)
-K, --tk 包含TCL/TK
-d, --debug 生成debug模式的exe文件
-w, --windowed, --noconsole 窗體exe文件(Windows Only)
-c, --nowindowed, --console 控制檯exe文件(Windows Only)
-o DIR, --out=DIR 設置spec文件輸出的目錄,默認在PyInstaller同目錄
--icon=<FILE.ICO> 加入圖標(Windows Only)
-v FILE, --version=FILE 加入版本信息文件
----------------------------------------------------------------------------------------------------------
我打包的時候是不帶有-d參數的,因此不知道這裏的debug是否爲pyinstaller裏面所指的debug, 我試着加上參數-d ,打包信息中仍是出現:
1 22894 ERROR: Assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found 2 23014 INFO: Searching for assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ... 3 23014 WARNING: Assembly not found
帶與不帶參數-d效果同樣!
沒辦法只能查看pyinstaller生成的文件吧,這一看仍是沒找到問題,但看到了解決辦法
在build目錄裏面有個.manifest文件
1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 2 <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"> 3 <assemblyIdentity name="qrcode_a" processorArchitecture="x86" type="win32" version="1.0.0.0"/> 4 <dependency> 5 <dependentAssembly> 6 <assemblyIdentity name="Microsoft.VC90.CRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" type="win32" version="9.0.21022.8"/> 7 </dependentAssembly> 8 </dependency> 9 <dependency> 10 <dependentAssembly> 11 <assemblyIdentity name="Microsoft.VC90.DebugCRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" type="win32" version="9.0.21022.8"/> 12 </dependentAssembly> 13 </dependency> 14 <dependency> 15 <dependentAssembly> 16 <assemblyIdentity language="*" name="Microsoft.Windows.Common-Controls" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" type="win32" version="6.0.0.0"/> 17 </dependentAssembly> 18 </dependency> 19 </assembly>
果真看到:Microsoft.VC90.DebugCRT
將.manifest文件中 Microsoft.VC90.DebugCRT 改成 Microsoft.VC90.CRT |
在打包運行,一切OK!
但爲何會出現debug模式,我仍是沒找到問題。