我试图使 Python 的最小部分作为我的 iOS 应用程序的一部分(静态库)用于内部脚本。我在 Mac OS X(10.7) 下使用 configure 并且成功。然后我很快就得到了可编译和可链接的 XCode 项目。问题是,当我尝试使用 Python 时
Py_NoSiteFlag=1;
Py_Initialize();
它失败并出现错误“致命的 Python 错误:异常引导错误”。在 _PyExc_Init() 中。我试图调试它,但不幸的是我无法理解它为什么会失败。可能是因为我不熟悉 Python 源代码,但无论如何,我需要移植它。试过2.7.3,或者3.2.3,结果和上面一样。任何解决方案或提示都会非常有帮助。
调用堆栈:
#0 0x300cba1c in __pthread_kill ()
#1 0x362e43ba in pthread_kill ()
#2 0x362dcbfe in abort ()
#3 0x00127d96 in Py_FatalError at /Users/mac_user/Downloads/Python-3.2.3/IOS/pythoncore/../../Python/pythonrun.c:2169
#4 0x00155328 in _PyExc_Init at /Users/mac_user/Downloads/Python-3.2.3/IOS/pythoncore/../../Objects/exceptions.c:2042
#5 0x00127ad4 in Py_InitializeEx at /Users/mac_user/Downloads/Python-3.2.3/IOS/pythoncore/../../Python/pythonrun.c:272
#6 0x0012846a in Py_Initialize at /Users/mac_user/Downloads/Python-3.2.3/IOS/pythoncore/../../Python/pythonrun.c:332
#7 0x000d6242 in testpython at /Users/mac_user/Downloads/Python-3.2.3/IOS/test/test/testmac.c:15
#8 0x000d618e in -[ViewController viewDidLoad] at /Users/mac_user/Downloads/Python-3.2.3/IOS/test/test/ViewController.m:23
#9 0x3283ff0e in -[UIViewController view] ()
#10 0x3283e2b4 in -[UIWindow addRootViewControllerViewIfPossible] ()
#11 0x3283a332 in -[UIWindow _setHidden:forced:] ()
#12 0x3283e28e in -[UIWindow _orderFrontWithoutMakingKey] ()
#13 0x3284cc60 in -[UIWindow makeKeyAndVisible] ()
#14 0x000d5ffe in -[AppDelegate application:didFinishLaunchingWithOptions:] at /Users/mac_user/Downloads/Python-3.2.3/IOS/test/test/AppDelegate.m:35
#15 0x3283e820 in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] ()
#16 0x32838b64 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
#17 0x3280d7d6 in -[UIApplication handleEvent:withNewEvent:] ()
#18 0x3280d214 in -[UIApplication sendEvent:] ()
#19 0x3280cc52 in _UIApplicationHandleEvent ()
#20 0x322b7e76 in PurpleEventCallback ()
#21 0x3113ba96 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#22 0x3113d83e in __CFRunLoopDoSource1 ()