【问题标题】:Having problems using py2exe使用 py2exe 时遇到问题
【发布时间】:2012-02-21 20:19:47
【问题描述】:

所以我正在尝试制作一个 exe 文件。我正在使用 python 2.7,据我所知,我安装了正确版本的 py2exe。我编写了一个简单的 setup.py 代码来创建 exe 文件。

但是,当我运行它时,我得到了错误:

错误:MSVCP90.dll:没有这样的文件或目录

现在,我尝试通过两种方式解决此问题:

  1. 我安装了 MSVCP90.dll 文件并将其与 python27 dll 一起放入,然后运行 ​​setup。这成功地创建了一个可执行文件。但是,当我尝试运行可执行文件时,它说:

程序无法启动,因为您的计算机中缺少 MSVCR90.dll。尝试重新安装程序以解决此问题。

我已经下载了这个 dll 并将其放入 python27 和 exe 中以查看会发生什么,但都不起作用。

  1. 我从安装文件中排除了 MSVCP90.dll 文件。同样,这成功地创建了一个可执行文件,但我在点击它时遇到了同样的错误。

我已经多次重新安装了 python 和 py2exe,但都没有帮助。

有没有人知道我可以做些什么来让这个可执行文件正常工作?

【问题讨论】:

  • 作为霰弹枪方法,您在将 MSVCP90.dll 与 Python27 dll 一起放入后是否重新启动?
  • 是的,我现在刚刚尝试过,但没有解决任何问题。
  • 我很困惑。您的错误是针对不同的 dll,'R90.dll,但您说的是 'P90.dll。
  • 是的,我知道。我也不明白!
  • 嗯,如果有什么不同的话,我也在使用 wxpython 库和我的代码。

标签: python executable py2exe


【解决方案1】:

正如您在 cmets 中提到的,您正在使用 wxpython。我对 wxpython 和 py2exe 有同样的问题。我通过将 MSVCP90.dll 的清单添加到 exe 文件来解决它。尝试将这些行添加到 setup.py 中,看看它是否有效。

manifest = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    version="5.0.0.0"
    processorArchitecture="x86"
    name="%(prog)s"
    type="win32"
  />
  <description>%(prog)s</description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
            level="asInvoker"
            uiAccess="false">
        </requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
            type="win32"
            name="Microsoft.VC90.CRT"
            version="9.0.21022.8"
            processorArchitecture="x86"
            publicKeyToken="1fc8b3b9a1e18e3b">
      </assemblyIdentity>
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
  </dependency>
</assembly>"""

...

windows = [{"script":"myscript.pyw",'other_resources': [(24,1,manifest)]}] 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-08
    • 2014-01-08
    • 2011-03-09
    • 2013-01-30
    • 2016-11-13
    • 2016-07-21
    • 2013-05-10
    相关资源
    最近更新 更多