我一直在开发一个使用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'],
}
}
)
编辑:是的,第二个错误似乎来自扭曲,但我怀疑这会导致第一个错误。 编辑2:嗯,也许第一个只是一个警告。
答案 0 :(得分:2)
这意味着常见的控制内容不会加载。第二个错误可能是第一个错误导致非致命性并且程序继续运行。
首先尝试:
(不捆绑选项)并检查问题是否仍然存在。这通常应该有效。
bundle_files = 3
尝试下一步:
因为您使用的是bundle选项1,所以可以检查哪个MSVC运行时DLL位于dist目录旁边的可执行文件中。我建议您在机器上找到所有MSVCRXX.dll并查看是否存在版本问题
答案 1 :(得分:0)
结果#1只是一个警告,而#2是通过显式模块包含
来修复的