我使用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文件,并取消了对Internet访问权限的注释,现在我收到了超时错误。
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/