py2exe:由于 DLL,已编译的 Python Windows 应用程序将无法运行 [英] py2exe: Compiled Python Windows Application won't run because of DLL

查看:33
本文介绍了py2exe:由于 DLL,已编译的 Python Windows 应用程序将无法运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我承认我对 Python 非常陌生,我还不知道我在做什么.最近我使用 Python 2.6.2 和 wxPython 2.8 创建了一个非常小的 Windows 应用程序.而且效果很好;我对它的正常运行情况感到非常满意.通常我的意思是当我直接通过 Python 解释器调用它时,就像这样:

I will confess I'm very new to Python and I don't really know what I'm doing yet. Recently I created a very small Windows application using Python 2.6.2 and wxPython 2.8. And it works great; I'm quite pleased with how well it works normally. By normally I mean when I invoke it directly through the Python interpreter, like this:

> python myapp.py

但是,我想更进一步,实际将其编译为独立的可执行文件.所以我遵循了使用 py2exe 的 wxPython wiki 中的这些说明.起初它在命令行中给了我错误,说缺少 MSVCR90.dll.然后我将 MSVCR90.dll 复制到我的 Python\DLLs 文件夹中.起初看起来像是修复了它,因为它成功地完成了它需要做的事情.它确实以一个快速警告结束,该程序依赖于一些 DLL 文件,我可能需要也可能不需要分发它们.

However, I wanted to go a step further and actually compile this into a standalone executable file. So I followed these instructions from the wxPython wiki which utilize py2exe. At first it gave me errors in the command line, saying MSVCR90.dll was missing. Then I copied MSVCR90.dll to my Python\DLLs folder. That looked at first like it fixed it, since it successfully did what it needed to do. It did finish with a quick warning that there were some DLL files the program depends on and I may or may not need to distribute them.

所以我导航到 py2exe 创建的 dist 文件夹并尝试运行我的可执行文件.但是尝试打开它只会弹出一个错误对话框,上面写着:

So I navigated into the dist folder that py2exe had created and tried running my executable. But trying to open it only popped up an error dialog that said:

This application failed to start because MSVCR90.dll was not found.
Re-installing the application may fix this problem.

所以我继续将 MSVCR90.dll 再次复制到这个 dist 文件夹中.但这并没有奏效.然后我把它复制到WINDOWS\system32目录下.那也没有做到.我需要做什么才能让这件事发挥作用?

So I went ahead and copied MSVCR90.dll again into this dist folder. But that didn't do the trick. Then I copied it into the WINDOWS\system32 directory. That didn't do it either. What do I need to do to get this thing to work?

推荐答案

您不能只复制 msvcr*.dll - 它们需要使用并行程序集的规则进行设置.您可以按照 Sam 指出的那样通过安装可再发行包来实现此目的,或者只要您遵守规则,您也可以将它们放在可执行文件旁边.

You can't just copy msvcr*.dll - they need to be set up using the rules for side-by-side assemblies. You can do this by installing the redistributable package as Sam points out, or you can put them alongside your executables as long as you obey the rules.

请参阅此处的将 Visual C++ 库 DLL 部署为私有程序集"部分:How to Deploy using XCopy 了解详情,但基本上你的应用程序看起来像这样:

See the section "Deploying Visual C++ library DLLs as private assemblies" here: How to Deploy using XCopy for details, but basically your application looks like this:

c:\My App\MyApp.exe
c:\My App\Microsoft.VC90.CRT\Microsoft.VC90.CRT.manifest
c:\My App\Microsoft.VC90.CRT\msvcr90.dll

这样做的一个好处是非管理员用户可以使用您的应用程序(我相信您需要成为管理员才能通过可再发行安装程序安装运行时).而且不需要任何安装程序 - 您只需将文件复制到 PC 上即可.

One benefit of this is that non-admin users can use your app (I believe you need to be an admin to install the runtime via the redistributable installer). And there's no need for any installer - you can just copy the files onto a PC and it all works.

这篇关于py2exe:由于 DLL,已编译的 Python Windows 应用程序将无法运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆