解决Pyqt打包后运行报错:应用程序无法启动 因为程序的并行配置不正确

做了一个生成二维码的小程序:http://www.cnblogs.com/dcb3688/p/4241048.html

直接运行脚本没问题,用pyinstaller打包后再运行就直接报错了:

应用程序无法启动 因为程序的并行配置不正确。有关详细信息,请参阅应用程序事件日志,或使用命令行 sxstrace.exe 工具。

解决Pyqt打包后运行报错:应用程序无法启动 因为程序的并行配置不正确

网上找的解决方法:

1.   安装Microsoft Visual C++ 2008 Redistributable

2.  开始 - 运行(输入services.msc)- 确定或回车,打开:服务(本地),开启Windows Modules Installer服务

第一种,我电脑已经安装VC2008,且VC2005 和VC2010 都安装了,  排除!

第二种,打开本地服务,发现Windows Modules Installer  已经是开启的, 排除!

所以还是在打包的信息中寻找线索吧

找打包时的信息分析后发现:

 19753 INFO: Looking for run-time hooks
19754 INFO: Analyzing rthook C:\Python27\lib\site-packages\pyinstaller-2.1.1.dev0-py2.7.egg\PyInstaller\loader\rthooks\pyi_rth_qt4plugins.py
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
19954 INFO: Analyzing rthook C:\Python27\lib\site-packages\pyinstaller-2.1.1.dev0-py2.7.egg\PyInstaller\loader\rthooks\pyi_rth_Image.py
22815 INFO: Adding Microsoft.VC90.DebugCRT to dependent assemblies of final executable
22894 INFO: Searching for assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
22894 WARNING: Assembly not found
22894 ERROR: Assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found
23014 INFO: Searching for assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...

是缺少VC90.CRT,但在系统中是可以找的到的:

 608 INFO: wrote E:\www\pyqt\TEST\qrcode_a.spec
684 INFO: Testing for ability to set icons, version resources...
888 INFO: ... resource update available
892 INFO: UPX is not available.
1000 INFO: Processing hook hook-os
1273 INFO: Processing hook hook-time
1279 INFO: Processing hook hook-cPickle
1434 INFO: Processing hook hook-_sre
1914 INFO: Processing hook hook-cStringIO
2136 INFO: Processing hook hook-encodings
2161 INFO: Processing hook hook-codecs
4158 INFO: Extending PYTHONPATH with E:\www\pyqt\TEST
4161 INFO: checking Analysis
4161 INFO: Building Analysis because out00-Analysis.toc non existent
4161 INFO: running Analysis out00-Analysis.toc
4162 INFO: Adding Microsoft.VC90.CRT to dependent assemblies of final executable
11481 INFO: Searching for assembly x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
11485 INFO: Found manifest C:\Windows\WinSxS\Manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91.manifest
11508 INFO: Searching for file msvcr90.dll
11509 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll
11510 INFO: Searching for file msvcp90.dll
11511 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcp90.dll
11513 INFO: Searching for file msvcm90.dll
11513 INFO: Found file C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcm90.dll
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 ,打包信息中还是出现:

 22894 ERROR: Assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none not found
23014 INFO: Searching for assembly x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_none ...
23014 WARNING: Assembly not found

带与不带参数-d效果一样!

没办法只能查看pyinstaller生成的文件吧,这一看还是没找到问题,但看到了解决办法

在build目录里面有个.manifest文件

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="qrcode_a" processorArchitecture="x86" type="win32" version="1.0.0.0"/>
<dependency>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VC90.CRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" type="win32" version="9.0.21022.8"/>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VC90.DebugCRT" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b" type="win32" version="9.0.21022.8"/>
</dependentAssembly>
</dependency>
<dependency>
<dependentAssembly>
<assemblyIdentity language="*" name="Microsoft.Windows.Common-Controls" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" type="win32" version="6.0.0.0"/>
</dependentAssembly>
</dependency>
</assembly>

果然看到:Microsoft.VC90.DebugCRT

解决办法:

将.manifest文件中    Microsoft.VC90.DebugCRT      改为     Microsoft.VC90.CRT  

在打包运行,一切OK!

解决Pyqt打包后运行报错:应用程序无法启动 因为程序的并行配置不正确

解决Pyqt打包后运行报错:应用程序无法启动 因为程序的并行配置不正确

但为什么会出现debug模式,我还是没找到问题。

上一篇:Linux系统编程(27)——线程控制


下一篇:IGT一道笔试题