使用 py2exe 时遇到问题

发布于 2024-12-29 19:43:44 字数 572 浏览 5 评论 0原文

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

但是,当我运行它时,出现错误:

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

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

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

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

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

  1. 我排除了安装文件中使用的 MSVCP90.dll 文件。同样,这成功创建了一个可执行文件,但是当我单击它时遇到了相同的错误。

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

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

so I'm trying to make an exe file. I'm using python 2.7, and from what I can tell, I have the correct version of py2exe installed. I've written a simple setup.py code to create the exe file.

However, when I run it, I get the error:

error: MSVCP90.dll: No such file or directory

Now, I have tried fixing this in two ways:

  1. I installed the MSVCP90.dll file and put it in with the python27 dll's, and then ran setup. This successfully created an executable. However, when I tried to run the executable, it said:

The program can't start because MSVCR90.dll is missing from your computer. Try reinstalling the program to fix this problem.

I've downloaded this dll and placed it in with python27, and with the exe to see what'd happen, but neither worked.

  1. I excluded the MSVCP90.dll file from being used in the setup file. Again, this successfully created an executable, but I ran into the same error when clicking on it.

I've reinstalled python and py2exe numerous times, and that didn't help.

Does anyone have any ideas for what I can do to get this executable working?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枫以 2025-01-05 19:43:44

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

As you mentioned in the comments you are using wxpython. I had the same problem with wxpython and py2exe. I solved it by adding the manifest for MSVCP90.dll to exe file. Try to add these rows to setup.py and see if it works.

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)]}] 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文