【发布时间】:2015-09-27 16:47:15
【问题描述】:
我最近在我的 Android 手机上安装了 QPython 1.2.1 版,它在 Android 4.2.2 Jelly-Bean 上运行。我可以使用 QPython 上的控制台来执行一些 python 命令,但是在第一次安装 QPython 时运行 helloworld.py 脚本时遇到问题。
helloworld.py:
#-*-coding:utf8;-*-
#qpy:console
#qpy:2
import androidhelper
droid = androidhelper.Android()
line = droid.dialogGetInput()
s = "Hello, %s" % (line.result,)
droid.makeToast(s)
运行helloworld.py文件后控制台的输出是这样的:
Traceback (most recent call last):
File "/storage/sdcard0/com.hipipal.qpyplus/scripts/helloworld.py", line 12, in <module>
droid = androidhelper.Android()
File "/storage/sdcard0/com.hipipal.qpyplus/lib/python2.7/site-packages/androidhelper/sl4a.py", line 34, in __init__
self.conn = socket.create_connection(addr)
File "/QPython/QPython2-core/build/python-install/lib/python2.7/socket.py", line 553, in create_connection
socket.gaierror: [Errno 7] no address associated with hostname.
如果从控制台调用,androidhelper 模块方法也不起作用。
【问题讨论】:
-
这个
helloworld.py文件包含什么? -
编辑帖子并添加脚本 helloworld.py
-
你尝试过基本操作吗:重启手机、强制停止应用、清除缓存和本地应用数据、卸载并重新安装?
-
你试过 Qpython3 应用吗?
-
是的,我已经安装了 QPython3 应用程序并且结果相同。我还重新启动了手机,清除了缓存,卸载了两个应用程序并重新安装了......使用超级用户取消了手机的root(查看它是否有效),然后将手机恢复出厂设置并重新安装了QPython。但运气不好,我无法让这些模块工作。