我使用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()
答案 0 :(得分:1)
固定。防火墙阻止了对MYSQL服务器的访问,并且没有异常处理的错误导致应用程序崩溃。