py2exe 找不到模块

发布于 2024-12-03 09:16:41 字数 352 浏览 1 评论 0原文

我有一个包含许多模块和目录的Python项目。要运行的主程序是test_main.py:

    import PSI_Core.benchManager as bm
    import shutil
    import os

    manager = bm.benchManager();

我完全按照py2exe的过程为该项目创建一个exe文件。但是一旦创建了exe文件并运行它,它给出错误:

    ImportError: No module named PSI_Core.benchManager

有人有 py2exe 的经验吗?成功 ?

I have a python project with many modules and directories.The main program to run is test_main.py:

    import PSI_Core.benchManager as bm
    import shutil
    import os

    manager = bm.benchManager();

I follow exacty the procedure for py2exe to create an exe file for this project.But once the exe file is created and I run it , it gives error :

    ImportError: No module named PSI_Core.benchManager

Has anybody any experience with py2exe ? Success ?

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

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

发布评论

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

评论(2

流年里的时光 2024-12-10 09:16:41

我知道这不是一个直接的答案,但在尝试让 py2exe 工作半小时后,我放弃并尝试了 cx_Freeze,它效果非常好:

http://cx-freeze.sourceforge.net/cx_Freeze.html

五分钟之内,我就有了一个闪亮的可执行文件在等着我:-)

I know this isn't a direct answer but after half an hour of trying to get py2exe working, I gave up and tried cx_Freeze which works wonderfully:

http://cx-freeze.sourceforge.net/cx_Freeze.html

Within five minutes, I had a shiny executable waiting for me :-)

青丝拂面 2024-12-10 09:16:41

我对 py2exe 有一些经验,但大部分是无法找到解决问题的正确方法并诉诸解决方法和补丁。但是,您的问题很可能相对简单。如果 py2exe 找不到该模块,我建议您使用安装脚本手动包含模块。下面是它应该是什么样子的示例:

setup(
    options = {'py2exe': {'includes': "PSI_Core"}},
    windows = [{'script': "test_main.py"}]
)

I have some experience with py2exe, but most of it is not being able to find a proper fix to my problems and resorting to workarounds and patches. However, there is a good chance that your problem is relatively simple. If py2exe can't find the module, I suggest you use the setup script to manually include a module. Here is an example of what it should look like:

setup(
    options = {'py2exe': {'includes': "PSI_Core"}},
    windows = [{'script': "test_main.py"}]
)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文