wxPython和py2app,CreateActCtx错误0x00000008(没有足够的可用磁盘空间)

发布于 2024-09-16 08:26:10 字数 2497 浏览 9 评论 0原文

我一直在开发一个使用 wxPython 作为 GUI 库和 py2exe 的应用程序,以便我可以轻松分发它,但是我刚刚测试了 py2exe,启动可执行文件时出现以下错误。

12:13:08: Debug: src/helpers.cpp(140): 'CreateActCtx' failed with error 0x00000008 (Not enough disk space available.).
Traceback (most recent call last):
  File "eYoutubeMacros3.py", line 1, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "application\application.pyo", line 5, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "application\backend\backend.pyo", line 4, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "application\backend\extractor.pyo", line 5, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "twisted\web\client.pyo", line 17, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "twisted\web\error.pyo", line 188, in <module>
ImportError: cannot import name resource

导致 src/helpers.cpp 中错误的函数是

static ULONG_PTR wxPySetActivationContext()
{

    OSVERSIONINFO info;
    wxZeroMemory(info);
    info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 
    GetVersionEx(&info);
    if (info.dwMajorVersion < 5)
        return 0;

    ULONG_PTR cookie = 0;
    HANDLE h;
    ACTCTX actctx;
    TCHAR modulename[MAX_PATH];

    GetModuleFileName(wxGetInstance(), modulename, MAX_PATH);
    wxZeroMemory(actctx);
    actctx.cbSize = sizeof(actctx);
    actctx.lpSource = modulename;
    actctx.lpResourceName = MAKEINTRESOURCE(2);
    actctx.hModule = wxGetInstance();
    actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID;

    h = CreateActCtx(&actctx);
    if (h == INVALID_HANDLE_VALUE) {
        wxLogLastError(wxT("CreateActCtx"));
        return 0;
    }

    if (! ActivateActCtx(h, &cookie))
        wxLogLastError(wxT("ActivateActCtx"));

    return cookie;
}

最后是我的 py2exe 代码

setup(
    console = [self.target], # Contains some build info, is this is relevant I'll add it
    zipfile = 'library.dat',
    options = {
        'py2exe' : {
            'bundle_files' : 1,
            'dll_excludes' : ['w9xpopen.exe'],
            'optimize'     : 2,
            'dist_dir'     : '../dist/executables/',
            'compressed'   : True,
            #'excludes'     : ['doctest', 'pdb', 'unittest', 'difflib', 'inspect'],
        }
    }
)

编辑:是的,第二个错误似乎来自扭曲,但我怀疑这会导致第一个错误。 Edit2:嗯,也许第一个只是一个警告。

I've been developing an application that uses wxPython as the GUI librar, and py2exe so that I can easily distribute it, however I have just now tested py2exe and the following error appears when the executable is launched.

12:13:08: Debug: src/helpers.cpp(140): 'CreateActCtx' failed with error 0x00000008 (Not enough disk space available.).
Traceback (most recent call last):
  File "eYoutubeMacros3.py", line 1, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "application\application.pyo", line 5, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "application\backend\backend.pyo", line 4, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "application\backend\extractor.pyo", line 5, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "twisted\web\client.pyo", line 17, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "twisted\web\error.pyo", line 188, in <module>
ImportError: cannot import name resource

The function causing the error in src/helpers.cpp is

static ULONG_PTR wxPySetActivationContext()
{

    OSVERSIONINFO info;
    wxZeroMemory(info);
    info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 
    GetVersionEx(&info);
    if (info.dwMajorVersion < 5)
        return 0;

    ULONG_PTR cookie = 0;
    HANDLE h;
    ACTCTX actctx;
    TCHAR modulename[MAX_PATH];

    GetModuleFileName(wxGetInstance(), modulename, MAX_PATH);
    wxZeroMemory(actctx);
    actctx.cbSize = sizeof(actctx);
    actctx.lpSource = modulename;
    actctx.lpResourceName = MAKEINTRESOURCE(2);
    actctx.hModule = wxGetInstance();
    actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID;

    h = CreateActCtx(&actctx);
    if (h == INVALID_HANDLE_VALUE) {
        wxLogLastError(wxT("CreateActCtx"));
        return 0;
    }

    if (! ActivateActCtx(h, &cookie))
        wxLogLastError(wxT("ActivateActCtx"));

    return cookie;
}

And lastly my code for py2exe

setup(
    console = [self.target], # Contains some build info, is this is relevant I'll add it
    zipfile = 'library.dat',
    options = {
        'py2exe' : {
            'bundle_files' : 1,
            'dll_excludes' : ['w9xpopen.exe'],
            'optimize'     : 2,
            'dist_dir'     : '../dist/executables/',
            'compressed'   : True,
            #'excludes'     : ['doctest', 'pdb', 'unittest', 'difflib', 'inspect'],
        }
    }
)

Edit: Yes the second error seems to be from twisted but I doubt that causes the first error.
Edit2: Hmm perhaps the first one is just a warning.

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

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

发布评论

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

评论(2

同展鸳鸯锦 2024-09-23 08:26:10

这意味着通用控件的内容不会加载。第二个错误可能是第一个错误的结果,该错误不是致命的并且程序继续运行。

首先尝试:(

不要捆绑选项)并检查问题是否仍然出现。这通常应该有效。

bundle_files = 3 

尝试下一步:

既然您使用的是捆绑选项 1 ,您能否检查哪个 MSVC 运行时 DLL 位于可执行文件旁边的 dist 目录中。我建议你也找出你机器上的所有MSVCRXX.dll,看看是否存在版本问题

That means common controls stuff does not load. The second error could be a result of the first error which is non fatal and program continues to run.

try first :

(Don't bundle option) and check if the issue still appears. This should typically work.

bundle_files = 3 

try next:

Since, you are using bundle option 1 , Can you check which MSVC runtime DLL is located in the dist directory along side the executable. I would suggest that you also find out all MSVCRXX.dll on your machine and see if there are version issues

呆橘 2024-09-23 08:26:10

结果#1 只是一个警告,#2 已通过显式模块包含修复

Turned out #1 was just a warning, and #2 was fixed with an explicit module include

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