py2exe +当bundle_files = 1时pywin32 MemoryLoadLibrary导入失败

发布于 2024-09-12 00:27:30 字数 648 浏览 7 评论 0原文

我创建了一个使用 pywin32 的简单程序。我想将它部署为可执行文件,所以我对其进行了 py2exe 处理。我也不想要大量的文件,因此我将 bundle_files 设置为 1(意味着将所有内容捆绑在一起)。但是,当我尝试运行它时,我得到:

Traceback (most recent call last):
  File "pshelper.py", line 4, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "win32.pyc", line 8, in <module>
  File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32ui.pyd

在我的安装脚本中,我尝试将 packages=["win32ui"]includes=["win32ui"] 作为选项,但这没有帮助。如何让 py2exe 包含 win32ui.pyd?

如果我不要求它捆绑文件,我就不会遇到这个问题,所以我现在可以这样做,但我想知道如何让它正常工作。

I have created a simple program which uses pywin32. I want to deploy it as an executable, so I py2exe'd it. I also didn't want a huge amount of files, so I set bundle_files to 1 (meaning bundle everything together). However, when I attempt running it, I get:

Traceback (most recent call last):
  File "pshelper.py", line 4, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "win32.pyc", line 8, in <module>
  File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32ui.pyd

In my setup script, I tried doing packages=["win32ui"] and includes=["win32ui"] as options, but that didn't help. How can I get py2exe to include win32ui.pyd?

I don't have this problem if I don't ask it to bundle the files, so I can do that, for now, but I'd like to know how to get it to work properly.

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

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

发布评论

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

评论(4

街角迷惘 2024-09-19 00:27:30

您确定问题是未包含 win32ui.pyd 吗?堆栈跟踪与 wiki 中所述并不完全相同,但请查看:http: //www.py2exe.org/index.cgi/Py2exeAndWin32ui

Are you sure that the problem is that win32ui.pyd is not included? The stack trace isn't exactly the same as noted in the wiki, but check this out: http://www.py2exe.org/index.cgi/Py2exeAndWin32ui.

一张白纸 2024-09-19 00:27:30

迄今为止最有效的解决方法是简单地使用 ctypes 重新实现 pywin32 函数。这不需要另一个 .pyd 或 .dll 文件,因此可以避免该问题。

The work-around that has worked best so far is to simply re-implement the pywin32 functions using ctypes. That doesn't require another .pyd or .dll file so the issue is obviated.

一抹微笑 2024-09-19 00:27:30

您想尝试一下 PyInstaller 吗?我在 Windows 7 和 Ubuntu 10.04 上都使用过它,它就像魔术一样工作,即使我在 Windows 上编译为 .pyd 时也是如此。

我已经能够捆绑我用它开发的各种应用程序。

Do care to try out PyInstaller? I've used it both on Windows 7 and Ubuntu 10.04 and it worked like magic, even when I compiled to .pyd on Windows.

I've been able to bundle all sorts of applications that I've developed with it.

一腔孤↑勇 2024-09-19 00:27:30

我在尝试将 psutil 与 py2exe 捆绑时遇到同样的问题。这是我到目前为止发现的。

Traceback (most recent call last):
  File "wx_gui.py", line 43, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "psutil\__init__.pyc", line 85, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "psutil\_psmswindows.pyc", line 15, in <module>
  File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading _psutil_mswindows.pyd

当bundle_files = 3.zipfile可能被指定或可能为None时,我得到了这个回溯,我仍然遇到问题。

首先,我认为这是一个缺少的 dll,因为这个页面:
http://www.py2exe.org/index.cgi/ProblemsToBeFixed

我已复制我在 Python27 中找到的所有 dll 都放入与可执行文件相同的目录中,并将该目录路径添加到 os.environ['path'] 中。那没有用。

然后我尝试直接从站点包导入我的包。

我已将编译的可执行文件的整个 sys.path 替换为正常的 sys.path

sys.path = [r'C:\Python27\Lib\idlelib', ...]

我认为 .pyd 模块已导入,但 Visual c++ 向我抛出了这个非常难看的错误消息:

Runtime Error!
Program: {path}.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

我建议您尝试替换整个 sys.path 以查看它是否正常工作。如果是这样,您始终可以使单个可执行文件将必要的模块写入临时目录并将其添加到您的路径中。如果没有的话,我觉得这个问题很难解决。

I have the same problem trying to bundle psutil with py2exe. Here is what I found so far.

Traceback (most recent call last):
  File "wx_gui.py", line 43, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "psutil\__init__.pyc", line 85, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "psutil\_psmswindows.pyc", line 15, in <module>
  File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading _psutil_mswindows.pyd

I get this traceback when bundle_files = 3. zipfile may be specified or may be None, I still get the problem.

First, I thought this was a missing dll because of this page:
http://www.py2exe.org/index.cgi/ProblemsToBeFixed

I've copied all the dlls I found in Python27 into the same directory as the executable and added that directory path to os.environ['path']. That didn't worked.

Then I tried to import my package directly from site-packages.

I've replaced the whole sys.path of my compiled executable with my normal sys.path

sys.path = [r'C:\Python27\Lib\idlelib', ...]

I think the .pyd module got imported but Visual c++ threw me this really ugly error message:

Runtime Error!
Program: {path}.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

I suggest you try to replace the whole sys.path to see if it is working. If it is, you could always make your single executable write the necessary module into a temp directory and add it to your path. If not, I feel like this problem is going to be hard to solve.

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