我一直在开发一个使用 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:嗯,也许第一个只是一个警告。
最佳答案
这意味着通用控件的内容不会加载。第二个错误可能是第一个错误的结果,该错误不是致命的,程序继续运行。
先尝试:
(不捆绑选项)并检查问题是否仍然出现。这通常应该有效。
bundle_files = 3
尝试下一步:
既然您使用的是捆绑选项 1 ,您能否检查哪个 MSVC 运行时 DLL 位于可执行文件旁边的 dist 目录中。我建议您也找出您机器上的所有MSVCRXX.dll,看看是否存在版本问题
关于python - wxPython和py2app,CreateActCtx错误0x00000008(没有足够的可用磁盘空间),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3590440/