卡在iOS上的嵌入式Python初始化上。 我从Kivy项目中获取了构建脚本。 它生成了libpython2.7.a、Python27.zip并包含。在
所以,我的应用程序将zip解压到/Documents/lib/python2.7
尝试设置Python:
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
Py_SetPythonHome((char *)[docsDir UTF8String]);
Py_SetProgramName("");
Py_Initialize();
落在:
^{pr2}$据我所知,它无法定位Python主路径。 但如果我通过以下方式修复站点:
Py_NoSiteFlag=1;
PyRun_SimpleString("import sys as s\nprint(s.path)");
它输出有效路径:
['/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python27.zip', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/plat-darwin', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/plat-mac', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/plat-mac/lib-scriptpackages', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/lib-tk', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/lib-old', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/lib-dynload']
但是没有一个进口有效。 要使Python正确地与模块一起工作,我必须修复什么?在
已经自己修好了。 我的错误是: -需要将所有python/lib文件作为目录(而不是组)放在基本程序文件中 -在构建阶段添加此目录“上载资源”列表 -在构建阶段,把“上传资源”阶段放在“编译程序”之上。不知道为什么,但这有帮助。在
相关问题 更多 >
编程相关推荐