0

On Android, using QPython, when either running Kivy sample code or attempting interactive entry, importing kivy resulted in this error:

uu0_a96@RCT6203W46:/ $ /data/data/com.hipipal.qpyplus/files/bin/qpython.sh && exit
Python 2.7.2 (default, Oct 25 2014, 20:52:15)
[GCC 4.9 20140827 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import kivy
[INFO              ] Kivy v1.8.0
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/QPython/core/build/python-install/lib/python2.7/site-packages/kivy/__init__.py", line 254, in <module>
   File "/QPython/core/build/python-install/lib/python2.7/UserDict.py", line 23, in __getitem__
 KeyError: 'ANDROID_APP_PATH'

I tried adding the key to os.environ, with the path to the directory containing the .py files with kivy calls, and the import works.

r0-
  • 2,388
  • 1
  • 24
  • 29

2 Answers2

1

As I said before : You need to have #qpy:kivy part in the first line. At least that was what happened to me. I suppose that is because QPython is finding what type of app is it.

1

I ran into this same issue with QPython on Android. After adding the below three lines at the top of my Python code files (main.py) Kivy started getting called correctly.

    #-*-coding:utf8;-*-
    #qpy:2
    #qpy:kivy

I started a new Kivy project in QPython and found that it added those to the beginning of the main.py file.

rsturk
  • 11
  • 2
  • The developer of QPython for Android is using them as flags to get Kivy to work, apparently. I had just figured this out after posting, and now my sample code, and my tweaked code are loading properly. Thank you. – Bolan Moonward May 24 '15 at 01:39