py2exe在MSVCR80.dll上报错

1 投票
1 回答
2125 浏览
提问于 2025-04-16 03:22
from distutils.core import setup
import py2exe,sys,os

sys.argv.append('py2exe')

try:
        setup(
   options = {'py2exe': {'bundle_files': 1}}, 
   console=['my_console_script.py'], 
   zipfile = None,
   )
except Exception, e:
 print e

输出:

> running py2exe
> *** searching for required modules ***
> *** parsing results ***
> *** finding dlls needed *** Traceback (most recent call last):   File
> "C:\scripts\download_ghost_recon\setup.py",
> line 26, in <module>
>     zipfile = None,   File "C:\Python26\lib\distutils\core.py",
> line 162, in setup
>     raise SystemExit, error SystemExit: error: MSVCR80.dll: No
> such file or directory

我在Windows 7上使用Python 2.6

我该怎么做才能解决这个MSVCR80.dll的错误,并编译我的脚本呢?

在其他脚本中,我可以运行相同的setup.py而没有遇到这个错误。

这让我觉得在这个脚本中,py2exe需要这个MSVCR80.dll文件。

我还尝试了这段代码,是我在这里找到的:http://www.py2exe.org/index.cgi/OverridingCriteraForIncludingDlls,但也没有成功。

from distutils.core import setup
import py2exe,sys,os

origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
        if os.path.basename(pathname).lower() in ("msvcp71.dll", "dwmapi.dll"):
                return 0
        return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL

sys.argv.append('py2exe')

try:
        setup(
            options = {'py2exe': {'bundle_files': 1}}, 
            console=['my_console_script.py'], 
            zipfile = None,
            )
except Exception, e:
    print e

*编辑

我还在我的电脑上搜索了这个文件,发现它在以下位置:

C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.762_none_10b2f55f9bffb8f8
C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_none_d08d7da0442a985d
C:\Windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4927_none_d08a205e442db5b5

1 个回答

2

在你调用 setup 的时候,添加以下内容:

{ 'py2exe': { ...,
              'dll_excludes': [ 'msvcr80.dll', 'msvcp80.dll',
                                'msvcr80d.dll', 'msvcp80d.dll',
                                'powrprof.dll', 'mswsock.dll' ] }, ...

如果你想把可视化C运行时的DLL文件包含到你的应用程序里,可以看看微软提供的可分发运行时下载。可能你正在使用的某个库或模块在这个应用程序中被引入了,但在你提到的其他应用程序中没有。检查一下能不能用Visual Studio 2008重新编译它们可能是个好主意,因为标准的Python 2.6 Windows版本就是用这个工具创建的。

撰写回答