在安卓系统的kivymd中使用python 3.8 exchangelib时出错



我使用exchangelib从python中的kivymd访问我的邮件。当我在计算机上运行我的代码时,它工作起来没有问题。但是,当我在Android上通过buildozer部署它并在Android上启动我的应用程序时,我看到了解析器错误。请帮忙,我不明白问题的根源。

11-15 13:11:05.087 21267 22545 I python  :  Traceback (most recent call last):
11-15 13:11:05.087 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/cached_property.py", line 70, in __get__
11-15 13:11:05.089 21267 22545 I python  :  KeyError: 'resolver'
11-15 13:11:05.089 21267 22545 I python  :  
11-15 13:11:05.089 21267 22545 I python  :  During handling of the above exception, another exception occurred:
11-15 13:11:05.089 21267 22545 I python  :  
11-15 13:11:05.089 21267 22545 I python  :  Traceback (most recent call last):
11-15 13:11:05.090 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/dns/resolver.py", line 743, in read_resolv_conf
11-15 13:11:05.090 21267 22545 I python  :  FileNotFoundError: [Errno 2] No such file or directory: '/etc/resolv.conf'
11-15 13:11:05.091 21267 22545 I python  :  
11-15 13:11:05.091 21267 22545 I python  :  During handling of the above exception, another exception occurred:
11-15 13:11:05.091 21267 22545 I python  :  
11-15 13:11:05.091 21267 22545 I python  :  Traceback (most recent call last):
11-15 13:11:05.092 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/app/main.py", line 155, in <module>
11-15 13:11:05.092 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/app/main.py", line 151, in main
11-15 13:11:05.093 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/kivy/app.py", line 854, in run
11-15 13:11:05.094 21267 22545 I python  :    File "kivy/_event.pyx", line 707, in kivy._event.EventDispatcher.dispatch
11-15 13:11:05.094 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/app/main.py", line 63, in on_start
11-15 13:11:05.095 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/app/main.py", line 108, in get_mail
11-15 13:11:05.095 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/exchangelib/account.py", line 116, in __init__
11-15 13:11:05.096 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/exchangelib/autodiscover/discovery.py", line 24, in discover
11-15 13:11:05.097 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/exchangelib/autodiscover/discovery.py", line 123, in discover
11-15 13:11:05.097 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/exchangelib/autodiscover/discovery.py", line 429, in _step_1
11-15 13:11:05.098 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/exchangelib/autodiscover/discovery.py", line 338, in _attempt_response
11-15 13:11:05.099 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/exchangelib/autodiscover/discovery.py", line 255, in _get_unauthenticated_response
11-15 13:11:05.099 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/exchangelib/autodiscover/discovery.py", line 379, in _is_valid_hostname
11-15 13:11:05.100 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/cached_property.py", line 74, in __get__
11-15 13:11:05.100 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/exchangelib/autodiscover/discovery.py", line 154, in resolver
11-15 13:11:05.101 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/dns/resolver.py", line 695, in __init__
11-15 13:11:05.101 21267 22545 I python  :    File "/home/andrey/PycharmProjects/stats_delay_android/.buildozer/android/platform/build-armeabi-v7a/build/python-installs/stats_delay_android/dns/resolver.py", line 746, in read_resolv_conf
11-15 13:11:05.102 21267 22545 I python  :  dns.resolver.NoResolverConfiguration: None
11-15 13:11:05.102 21267 22545 I python  : Python for android ended.

exchangelib需要进行DNS查找才能使自动发现工作。NoResolverConfigurationdnspython包中的一个例外,它告诉您在系统中找不到任何关于要联系哪些名称服务器的信息。通常,这将位于/etc/resolv.conf中,如FileNotFoundError错误所示。

我不知道DNS在安卓系统上是如何工作的,也不知道Python如何访问安卓系统的DNS配置。如果无法让dnspython获取配置,可以在Resolver.nameservers属性中手动设置要使用的DNS服务器列表(例如[8.8.8.8](。您可以在exchangelib中通过Autodiscovery.DNS_RESOLVER_ATTRS属性对此进行配置:

from exchangelib.auto discover import Autodiscovery
Autodiscovery.DNS_RESOLVER_ATTRS['nameservers'] = ['8.8.8.8']

相关内容

  • 没有找到相关文章

最新更新