Windows Server 无法执行 py2exe 生成的应用程序

发布于 2024-08-16 05:12:59 字数 238 浏览 8 评论 0原文

一个简单的Python脚本需要在没有安装Python的Windows服务器上运行。

我使用 py2exe,它生成了一个健康的 dist 子目录,其中 script.exe 在本地计算机上运行良好。
但是,当我在服务器(Windows Server 2003 R2)上运行它时,它会生成以下内容:
系统无法执行指定的程序。

并且 ERRORLEVEL 为 9020。

有什么想法吗?

A simple python script needs to run on a windows server with no python installed.

I used py2exe, which generated a healthy dist subdirectory, with script.exe that runs fine on the local machine.
However, when I run it on the server (Windows Server 2003 R2), it produces this:
The system cannot execute the specified program.

and ERRORLEVEL is 9020.

Any ideas?

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

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

发布评论

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

评论(4

过潦 2024-08-23 05:12:59

为了使 py2exe 工作,您必须在应用程序中包含正确版本的 Microsoft C 运行时 DLL。

对于 Python2.6,这是 MSVCR90.dll 版本 9.0.21022.8,可以从 Microsoft Visual C++ 2008 Redistributable Package 获取:

http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf& displaylang=en

请注意,此安装程序的 SP1 包含不同版本的 DLL,因此无法运行。

今年早些时候我花了一段时间在 py2exe 教程中仔细解释了这一点,所以我将链接到该内容:
http://www.py2exe.org/index.cgi/Tutorial#Step5

For py2exe to work, you have to include the correct version of the Microsoft C runtime DLL with your application.

For Python2.6, this is MSVCR90.dll version 9.0.21022.8, which can be obtained from the Microsoft Visual C++ 2008 Redistributable Package:

http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en

NOTE that the SP1 of this installer contains a different version of the DLL, and will not work.

I spent a while earlier this year explaining this carefully in the py2exe tutorial, so I'll just link to that:
http://www.py2exe.org/index.cgi/Tutorial#Step5

江南烟雨〆相思醉 2024-08-23 05:12:59

它可能缺少一些必需的 DLL。尝试使用 depends.exe 来确定可能缺少的内容。它可能是一个 msvc-something-something.dll

It could be missing some required DLLs. Try using depends.exe to identify what might be missing. It's probably an msvc-something-something.dll

若无相欠,怎会相见 2024-08-23 05:12:59

我没有找到问题的原因,但在同一脚本上使用 python 2.5 和 py2exe 在服务器上运行良好。

我猜2.6下的py2exe有问题。

I did not find the cause to the problem, but using python 2.5 with py2exe on the same script worked fine on the server.

I guess there is something wrong with py2exe under 2.6.

掩于岁月 2024-08-23 05:12:59

由于 Python 2.6 是针对 Visual Studio 2008 构建的,因此目标计算机还必须具有 Visual Studio 2008 库(可从 Visual C++ 2008 可再发行组件包

我确认,在 Windows XP 或 Server 2003 的全新版本(两者都没有 Visual Studio 2008 可再发行组件)上,Python 2.6 py2exe 可执行文件将因上述错误而失败,但在安装可再发行组件包后,可执行文件可以正常运行。

Because Python 2.6 is built against Visual Studio 2008, the target machine must also have the Visual Studio 2008 libraries, available from the Visual C++ 2008 Redistributable package.

I confirmed that on a clean build of Windows XP or Server 2003 (neither of which have the Visual Studio 2008 redistributable), a Python 2.6 py2exe executable will fail with the aforementioned error, but after installing the redistributable package, the executable runs normally.

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