gpt4 book ai didi

android - Python Buildozer PyMySQL 无法连接

转载 作者:行者123 更新时间:2023-11-30 00:30:52 28 4
gpt4 key购买 nike

我已经使用 pymysql 模块在 kivy 中创建了一个应用程序来创建一个简单的登录系统。 python 文件在我的桌面上运行时没有错误,但是当我在我的 Nexus 平板电脑上运行该应用程序时,它崩溃并抛出以下错误。

有人可以找出这个问题的原因并指出正确的方向吗?谢谢。

06-07 12:07:35.319 10766 10786 I python  :  Traceback (most recent call     last):
06-07 12:07:35.342 10766 10786 I python : File "/home/andrew/Desktop/Python/Kivy/1-application/.buildozer/android/app/main.py", line 83, in <module>
06-07 12:07:35.343 10766 10786 I python : File "/home/andrew/Desktop/Python/Kivy/1-application/.buildozer/android/platform/build/dists/myapp/private/lib/python2.7/site-packages/pymysql/__init__.py", line 90, in Connect
06-07 12:07:35.344 10766 10786 I python : File "/home/andrew/Desktop/Python/Kivy/1-application/.buildozer/android/platform/build/dists/myapp/private/lib/python2.7/site-packages/pymysql/connections.py", line 706, in __init__
06-07 12:07:35.345 10766 10786 I python : File "/home/andrew/Desktop/Python/Kivy/1-application/.buildozer/android/platform/build/dists/myapp/private/lib/python2.7/site-packages/pymysql/connections.py", line 963, in connect
06-07 12:07:35.346 10766 10786 I python : pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '<IP ADDRESS>' ([Errno 13] Permission denied)")
06-07 12:07:35.402 10766 10786 I python : Python for android ended.

编辑:我进入 buildozer.spec 文件并取消注释互联网访问权限,现在我收到超时错误。

pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '<IP ADDRESS>' (timed out)")

这是我如何尝试连接到我的数据库的示例...

from kivy.app import App
from kivy.uix.gridlayout import GridLayout
import pymysql.cursors

class LoginScreen(GridLayout):
#CONTENT HERE

class SimpleKivy(App):
def build(self):
return LoginScreen()

if __name__ == "__main__":
#Error Happens Here
connection = pymysql.connect(host="<IP ADDRESS>", user="usr", password="pswd", db="slogin")

SimpleKivy().run()

最佳答案

已修复。防火墙阻止了对 MYSQL 服务器的访问,没有异常处理的错误导致应用程序崩溃。

关于android - Python Buildozer PyMySQL 无法连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44419136/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com