我最近在我的安卓手机上安装了QPython版本-1.2.1,它运行在Android4.2.2果冻豆上。我可以使用 QPython 上的控制台执行一些python命令,但是在第一次安装QPython时运行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模块方法也不能工作。
发布于 2016-03-31 08:40:19
也许/etc/主机被修改了。将其还原为原始状态,如下所示:
127.0.0.1本地主机
再试一次qpython。
发布于 2017-11-24 15:19:55
您正在使用旧的qpython,请试一试最新的https://github.com/qpython-android/qpython/releases。
https://stackoverflow.com/questions/32810347
复制相似问题