android 名称错误:名称“sys”未定义,与buildozer一起出现

wmvff8tz  于 2023-02-06  发布在  Android
关注(0)|答案(1)|浏览(109)

我试图用包tapo-plug,kivy和buildozer做一个Android应用程序,但打开后应用程序直接崩溃。我从来没有这样做过。这是我的手机发送的错误消息:

02-04 16:32:53.560 23072 23113 I python  :  Traceback (most recent call last):
02-04 16:32:53.561 23072 23113 I python  :    File "/home/daniel/test/ServerManagementApp/.buildozer/android/app/main.py", line 19, in <module>
02-04 16:32:53.561 23072 23113 I python  :    File "/home/daniel/test/ServerManagementApp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Vexludus/arm64-v8a/tapo_plug/tapoPlugApi.py", line 11, in <module>
02-04 16:32:53.561 23072 23113 I python  :    File "/home/daniel/test/ServerManagementApp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Vexludus/arm64-v8a/tapo_plug/tapoEncryption.py", line 7, in <module>
02-04 16:32:53.561 23072 23113 I python  :    File "/home/daniel/test/ServerManagementApp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Vexludus/arm64-v8a/Crypto/PublicKey/RSA.py", line 38, in <module>
02-04 16:32:53.561 23072 23113 I python  :    File "/home/daniel/test/ServerManagementApp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Vexludus/arm64-v8a/Crypto/IO/PKCS8.py", line 44, in <module>
02-04 16:32:53.561 23072 23113 I python  :    File "/home/daniel/test/ServerManagementApp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Vexludus/arm64-v8a/Crypto/IO/_PBES.py", line 43, in <module>
02-04 16:32:53.561 23072 23113 I python  :    File "/home/daniel/test/ServerManagementApp/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/Vexludus/arm64-v8a/Crypto/Hash/MD5.py", line 45, in <module>
02-04 16:32:53.561 23072 23113 I python  :  NameError: name 'sys' is not defined
02-04 16:32:53.561 23072 23113 I python  : Python for android ended.

我已经设置了tapo-plug,Crypto,PyCryptodome,pyjwkest,pycrypto作为要求。
这是我第一次做这种事。
这是发生错误的脚本部分:

from Crypto.Util.py3compat import *

从Crypto. Utility原始API导入(加载pypcryptodome原始库、空指针、智能指针、创建字符串缓冲区、获取原始缓冲区、c大小t、c_uint8_ptr)
原始数据库=加载原始数据库(“加密哈希表MD5”,“”#定义MD5数字数据库大小16

int MD5_init(void **shaState);
                    int MD5_destroy(void *shaState);
                    int MD5_update(void *hs,
                                      const uint8_t *buf,
                                      size_t len);
                    int MD5_digest(const void *shaState,
                                      uint8_t digest[MD5_DIGEST_SIZE]);
                    int MD5_copy(const void *src, void *dst);

                    int MD5_pbkdf2_hmac_assist(const void *inner,
                                        const void *outer,
                                        const uint8_t first_digest[MD5_DIGEST_SIZE],
                                        uint8_t final_digest[MD5_DIGEST_SIZE],
                                        size_t iterations);
                    """)
mwkjh3gx

mwkjh3gx1#

这是很难猜测是什么原因导致你的问题没有最小的可复制的样本。我做了简单的Kivy项目,它在Windows和Android下工作没有问题。
建筑推土机.规范要求:

requirements = python3,kivy,pycryptodome,pkcs7,Crypto,tapo-plug,requests,urllib3,charset_normalizer,chardet,idna

样本代码:

from kivy.app import App
from Crypto.Util.py3compat import *  # pip install pycryptodome
from Crypto.Hash.MD5 import *
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from tapo_plug import tapoPlugApi  # pip install tapo-plug

class app(App):

    device = {
        "tapoIp": "127.0.0.1",
        "tapoEmail": "dummy@dummy.com",
        "tapoPassword": "dummy"
    }

    def build(self):
        return BoxLayout(orientation='vertical')

    def on_start(self):
        self.root.add_widget(Label(text=str(b('test'))))
        self.root.add_widget(Label(text=MD5Hash(b'test').hexdigest()))
        try:
            self.root.add_widget(Label(text=tapoPlugApi.getDeviceInfo(self.device)))
        except Exception as e:
            self.root.add_widget(Label(text=str(e)))
            pass

app().run()

相关问题