#
周海汉 /文
2010.2.7
今天用py2exe打包python程序,结果遇到如下错误:
- ** searching for required modules **
- ** parsing results **
- creating python loader for extension ‘wx.misc’ (c:python26libsite-packages
- wx-2.8-msw-unicodewx_misc_.pyd -> wx.misc.pyd)
- creating python loader for extension ‘select’ (c:python26DLLsselect.pyd -> se
- lect.pyd)
- creating python loader for extension ‘unicodedata’ (c:python26DLLsunicodedata
- .pyd -> unicodedata.pyd)
- creating python loader for extension ‘wx.windows’ (c:python26libsite-packag
- eswx-2.8-msw-unicodewx_windows_.pyd -> wx.windows.pyd)
- creating python loader for extension ‘wx.core’ (c:python26libsite-packages
- wx-2.8-msw-unicodewx_core_.pyd -> wx.core.pyd)
- creating python loader for extension ‘wx.gdi’ (c:python26libsite-packagesw
- x-2.8-msw-unicodewx_gdi_.pyd -> wx.gdi.pyd)
- creating python loader for extension ‘wx.controls’ (c:python26libsite-packa
- geswx-2.8-msw-unicodewx_controls_.pyd -> wx.controls.pyd)
- creating python loader for extension ‘bz2’ (c:python26DLLsbz2.pyd -> bz2.pyd)
- ** finding dlls needed **
- error: MSVCP90.dll: No such file or directory
** searching for required modules ** ** parsing results ** creating python loader for extension ‘wx.misc’ (c:python26libsite-packages wx-2.8-msw-unicodewx_misc_.pyd -> wx.misc.pyd) creating python loader for extension ‘select’ (c:python26DLLsselect.pyd -> se lect.pyd) creating python loader for extension ‘unicodedata’ (c:python26DLLsunicodedata .pyd -> unicodedata.pyd) creating python loader for extension ‘wx.windows’ (c:python26libsite-packag eswx-2.8-msw-unicodewx_windows_.pyd -> wx.windows.pyd) creating python loader for extension ‘wx.core’ (c:python26libsite-packages wx-2.8-msw-unicodewx_core_.pyd -> wx.core.pyd) creating python loader for extension ‘wx.gdi’ (c:python26libsite-packagesw x-2.8-msw-unicodewx_gdi_.pyd -> wx.gdi.pyd) creating python loader for extension ‘wx.controls’ (c:python26libsite-packa geswx-2.8-msw-unicodewx_controls_.pyd -> wx.controls.pyd) creating python loader for extension ‘bz2’ (c:python26DLLsbz2.pyd -> bz2.pyd) ** finding dlls needed ** error: MSVCP90.dll: No such file or directory
** finding dlls needed **
error: MSVCP90.dll: No such file or directory
解决办法:
因为包含wxpython模块,需下载MSVCP90.DLL 并拷贝到Python26/DLLs 目录下
1.直接下载安装微软vc++ 2008 分发包:http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf
会安装到:
C:WINDOWSWinSxSx86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30411.0_x-ww_71382c73目录下
可能不同的系统会稍有不同,但C:WINDOWSWinSxSx86_Microsoft.VC90…这个是一致的。
而且直接在windows里搜索搜不到。
2.单独下载MSVCP90.DLL 并拷贝到Python26/DLLs 目录下
http://www.dll-files.com/dllindex/dll-files.shtml?msvcp90
3.由于本机也能运行,确认不需要msvcp90.dll,可以直接在脚本中去掉包含该dll。但可能在其他人机器不能运行。
在py2exe的setup.py包含如下的代码:
- distutils.core.setup(
- options = {
- “py2exe”: {
- “dll_excludes”: [“MSVCP90.dll”]
- }
- },
- …
- )
distutils.core.setup( options = { “py2exe”: { “dll_excludes”: [“MSVCP90.dll”] } }, … )
或
- fro m distutils.core import setup
- import py2exe
- setup(
- windows=[‘main.py’],
- options = {
- “py2exe”:
- {“dll_excludes”:[“MSVCP90.dll”]}
- }
- )
from distutils.core import setup import py2exe setup( windows=[‘main.py’], options = { “py2exe”: {“dll_excludes”:[“MSVCP90.dll”]} } )
4.如果已经安装msvc++ 2008以上,而找不到目录,可以如下设置,找到分发目录。
- import sys
- sys.path.append(‘c:/Program Files/Microsoft Visual Studio 9.0/VC/redist/x86/Microsoft.VC90.CRT’)
如非注明转载, 均为原创. 本站遵循知识共享CC协议,转载请注明来源