qpython控制台无法运行helloworld.py

时间:2015-09-27 16:47:15

标签: android python qpython

我最近在我的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模块方法也不起作用。

2 个答案:

答案 0 :(得分:0)

可能修改了/ etc / hosts。将其恢复为原始状态,如下所示:

  

127.0.0.1 localhost

再次尝试qpython。

答案 1 :(得分:0)

您使用旧的qpython,请尝试使用最新的https://github.com/qpython-android/qpython/releases

相关问题