简体   繁体   English

无法将请求模块加载到Kivy iOS应用

[英]Can't load requests module to Kivy iOS app

When I try to load the requests module into my Python code with 当我尝试将请求模块加载到我的Python代码中时

import requests

and then build the Kivy app using the toolchain, it crashes on in the iOS simulator. 然后使用工具链构建Kivy应用,该应用将在iOS模拟器中崩溃。 (I am developing on macOS.) (我在macOS上进行开发。)

I have used 我用过

kivy -m pip install requests

which appears to install requests into the Kivy virtualenv, but it still crashes the iOS simulator. 似乎可以将请求安装到Kivy virtualenv中,但仍会使iOS模拟器崩溃。

I have even tried copying the requests library itself and placing it in my project as a subdirectory. 我什至尝试复制请求库本身并将其作为子目录放置在我的项目中。 In this instance it will run correctly in macOS but still crash in the iOS simulator. 在这种情况下,它将在macOS中正常运行,但在iOS模拟器中仍然崩溃。

When I say "it crashes", what I mean is that the simulator tries to open the app, then closes it after showing a black screen for about one second. 当我说“它崩溃”时,我的意思是模拟器尝试打开该应用程序,然后在显示黑屏约一秒钟后将其关闭。 If I do not include the "import requests" line, the app opens fine and goes to the correct initial screen. 如果我不包括“导入请求”行,则该应用程序可以正常打开并进入正确的初始屏幕。 Here are the Xcode logs from the simulator run: 这是模拟器运行的Xcode日志:

2016-10-28 22:25:57.433587 mentat[9488:154501] bundleid: org.kivy.mentat, enable_level: 0, persist_level: 0, propagate_with_activity: 0
2016-10-28 22:25:57.442428 mentat[9488:154501] subsystem: com.apple.siri, category: Intents, enable_level: 1, persist_level: 1, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0, enable_private_data: 0
2016-10-28 22:25:57.486633 mentat[9488:154643] subsystem: com.apple.UIKit, category: HIDEventFiltered, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-28 22:25:57.516511 mentat[9488:154643] subsystem: com.apple.UIKit, category: HIDEventIncoming, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-28 22:25:57.535126 mentat[9488:154640] subsystem: com.apple.BaseBoard, category: MachPort, enable_level: 1, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0, enable_private_data: 0
2016-10-28 22:25:57.592160 mentat[9488:154501] subsystem: com.apple.UIKit, category: StatusBar, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1, privacy_setting: 2, enable_private_data: 0
2016-10-28 22:25:57.594924 mentat[9488:154501] subsystem: com.apple.BackBoardServices.fence, category: App, enable_level: 1, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0, enable_private_data: 0
2016-10-28 22:25:57.794404 mentat[9488:154501] subsystem: com.apple.BackBoardServices.fence, category: Workspace, enable_level: 1, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 0, privacy_setting: 0, enable_private_data: 0
2016-10-28 22:25:57.796 mentat[9488:154501] Available orientation: KIVY_ORIENTATION=LandscapeLeft LandscapeRight Portrait PortraitUpsideDown
2016-10-28 22:25:57.797 mentat[9488:154501] PythonHome is: /Users/matt/Library/Developer/CoreSimulator/Devices/529262BC-AA42-4190-8212-77C1D2723BA7/data/Containers/Bundle/Application/F52EAFF5-5458-4121-A7A9-749796FB82AF/mentat.app
2016-10-28 22:25:57.798 mentat[9488:154501] Initializing python
2016-10-28 22:25:57.955 mentat[9488:154501] Running main.pyo: /Users/matt/Library/Developer/CoreSimulator/Devices/529262BC-AA42-4190-8212-77C1D2723BA7/data/Containers/Bundle/Application/F52EAFF5-5458-4121-A7A9-749796FB82AF/mentat.app/YourApp/main.pyo
2016-10-28 22:25:57.999 mentat[9488:154501] Application quit abnormally!
2016-10-28 22:25:58.004 mentat[9488:154501] Leaving

I don't find the messages to be informative. 我发现消息内容不多。 Perhaps there is a logging option I can turn on? 也许有一个我可以打开的日志记录选项?

I've discovered that the current version of requests (2.11.1) doesn't work with iOS, or at least not with Kivy-iOS. 我发现当前版本的requests (2.11.1)不适用于iOS,或者至少不适用于Kivy-iOS。 Manually cloning requests2.9.1 and putting it in my project directory solved the problem. 手动克隆requests2.9.1并将其放在我的项目目录中可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM