What does ’compile Kivy’ actually mean? (”missing kivy._clock often indicates the Cython code has not been compiled.”)

425 views
Skip to first unread message

Henrik R.

unread,
Sep 23, 2023, 1:34:02 PM9/23/23
to Kivy users support

Hi!


My Python-Kivy app was actually working, and released on Google Play store in open test, using Buildozer. Then I accidentally did a ’buildozer distclean’ and ’buildozer appclean’ and as you can see on another thread – https://groups.google.com/g/kivy-users/c/EIqHbDLZ2ZY – that created a large amount of problems.

Now it (almost) compiles, but depending on which Kivy version I specify in buildozer.spec, I get different results:

If I choose Kivy v. 2.2.1 the app runs, but my modification of TouchTracer doesn’t work (as I described in https://github.com/kivy/kivy/issues/7861 in April 2022).

But if I switch back to Kivy v. 2.0.0 I get this error:

"Unable to import kivy._clock. Have you perhaps forgotten to compile kivy? Kivy contains Cython code which needs to be compiled. A missing kivy._clock often indicates the Cython code has not been compiled. Please follow the installation instructions and make sure to compile Kivy"


But I am not sure how I should 'compile Kivy'?

Is it this?:

python -m pip install kivy[base] kivy_examples

(In Terminal, on Ubuntu linux, while in the project directory and after activating my new specific venv?)

Is the Kivy compilation erased every time I do a 'buildozer appclean'?


I look forward to hear from you guys. Thank you. :-)


Robert

unread,
Sep 23, 2023, 3:42:46 PM9/23/23
to Kivy users support
Buildozer does this for you, for most platforms Kivy is installed with pip having been pre-compiled

Like every other Python package Buildozer does not use the locally installed (with pip) package,
it gets its own copy, which appclean will delete.

The Kivy compile errors from Buildozer: I expect this is a Kivy version and Cython version incompatibility.
But I only know what Cython the current release version of Kivy requires.

TouchTracer Demo I know nothing about. But looking at your logs it is apparently ` OpenGLRenderer` related,
that and `[INFO ] [GL ] OpenGL renderer <b'Adreno (TM) 505'> ` makes me wonder.

So if the issue still exists on Android with your Moto device and all of:
1) the *unchanged* TouchTracer Demo, 
2) Kivy 2.2.1, 
3) Cython 0.29.33, 
4) develop version of p4a .
Then there may be a p4a issue.

I get that you opened an issue and it was closed. If all 4 of the above are true open another one.

Henrik R.

unread,
Sep 24, 2023, 2:52:44 PM9/24/23
to Kivy users support
Thank you!

You indicate 2 possible roads, so I chose to try Kivy v. 2.0.0 again:
My interpretation of https://github.com/kivy/kivy/commit/0d3bc288f66c5fea3e41c24c0cd193819cf0cf59 is that Kivy v. 2.0.0 is compatible with Cython v. 0.29.21, so I did this in Terminal on Ubuntu 20.04:
$ pip3 install --upgrade Cython==0.29.21 virtualenv
$ buildozer appclean
$ buildozer android debug deploy run

But I still get the ”missing kivy._clock" error when the app tries to run on my Android phone.
I also tried:
$ pip3 install --upgrade Cython==0.29.14 virtualenv
But that gave a Toolchain compile error.

I am a bit clueless... :-)

Robert

unread,
Sep 24, 2023, 10:02:56 PM9/24/23
to Kivy users support
check the Cython version  (.21 may not be an upgrade from .33)
I have a concern this approach may break something else - but there is only one way to find out.

Henrik R.

unread,
Sep 25, 2023, 5:07:32 AM9/25/23
to Kivy users support
Do you mean this:
(newvenv) h@hk:/ ... /GeoESP-android$ cython -V
Cython version 0.29.21

It leads to this:

 I python  : Android kivy bootstrap done. __name__ is __main__
 I python  : AND: Ran string
 I python  : Run user program, change dir and execute entrypoint
 I python  : [INFO   ] [Logger      ] Record log in /data/user/0/dk.transformation.geoesptraining/files/app/.kivy/logs/kivy_23-09-25_1.txt
 I python  : [INFO   ] [Kivy        ] v2.0.0
 I python  : [INFO   ] [Kivy        ] Installed at "/data/user/0/dk.transformation.geoesptraining/files/app/_python_bundle/site-packages/kivy/__init__.pyc"
 I python  : [INFO   ] [Python      ] v3.10.10 (main, Sep 25 2023, 10:15:25) [Clang 14.0.6 (https://android.googlesource.com/toolchain/llvm-project 4c603efb0
 I python  : [INFO   ] [Python      ] Interpreter at ""
 I python  : [ERROR  ] [Clock       ] Unable to import kivy._clock. Have you perhaps forgotten to compile kivy? Kivy contains Cython code which needs to be compiled. A missing kivy._clock often indicates the Cython code has not been compiled. Please follow the installation instructions and make sure to compile Kivy
 I python  :  Traceback (most recent call last):
 I python  :    File "/mnt/4AF15A0435E762B4/mypython/GeoESP-android/.buildozer/android/app/main.py", line 38, in <module>
 I python  :    File "/mnt/4AF15A0435E762B4/mypython/GeoESP-android/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/python-installs/geoesptraining/armeabi-v7a/kivy/uix/label.py", line 284, in <module>
 I python  :    File "/mnt/4AF15A0435E762B4/mypython/GeoESP-android/.buildozer/android/platform/build-armeabi-v7a_arm64-v8a/build/python-installs/geoesptraining/armeabi-v7a/kivy/clock.py", line 466, in <module>
 I python  :  ModuleNotFoundError: No module named 'kivy._clock'
 I python  : Python for android ended.

Robert

unread,
Sep 25, 2023, 12:32:20 PM9/25/23
to Kivy users support
Yes that is what I was wondering about.

Henrik R.

unread,
Sep 26, 2023, 11:24:47 AM9/26/23
to Kivy users support
But how do I solve it?

Henrik R.

unread,
Oct 4, 2023, 5:00:22 PM10/4/23
to Kivy users support
The problems that this was a part of have been solved - see https://groups.google.com/g/kivy-users/c/EIqHbDLZ2ZY .
Reply all
Reply to author
Forward
0 new messages