使用py2exe时遇到问题

时间:2012-01-29 21:48:14

标签: python executable py2exe

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

然而,当我运行它时,我收到错误:

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

现在,我尝试过以两种方式解决这个问题:

  1. 我安装了MSVCP90.dll文件并将其与python27 dll一起放入,然后运行安装程序。这成功创建了可执行文件。但是,当我尝试运行可执行文件时,它说:
  2. 程序无法启动,因为您的计算机缺少MSVCR90.dll。尝试重新安装该程序以解决此问题。

    我已经下载了这个dll并将其放在python27中,并使用exe来查看会发生什么,但都没有用。

    1. 我排除了MSVCP90.dll文件在安装文件中的使用。同样,这成功地创建了一个可执行文件,但是在点击它时遇到了同样的错误。
    2. 我已经多次重新安装python和py2exe,但这没有帮助。

      有没有人对我能做些什么来让这个可执行文件有效?

1 个答案:

答案 0 :(得分:0)

正如您在评论中提到的那样,您正在使用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)]}] 
相关问题