Compiling cython in venv for Apple M1 chip

942 views
Skip to first unread message

Josef Hamelink

unread,
Nov 16, 2021, 7:16:22 AM11/16/21
to Kivy users support
Hello, I would like to use Kivy for some of my university projects and I tried to install it using the default instructions found on kivy.org, but there seems to be something missing. I am using vscode. This is the output I get when running the default "Hello world!" program:
----------------
[INFO   ] [Logger      ] Record log in /Users/jdhamelink/.kivy/logs/kivy_21-11-16_6.txt
[INFO   ] [Kivy        ] v2.0.0
[INFO   ] [Kivy        ] Installed at "/Users/jdhamelink/Local/UNO_X/kivy_venv/lib/python3.8/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.8.9 (default, Aug  3 2021, 19:21:54) 
[Clang 13.0.0 (clang-1300.0.29.3)]
[INFO   ] [Python      ] Interpreter at "/Users/jdhamelink/Local/UNO_X/kivy_venv/bin/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
 Traceback (most recent call last):
   File "/Users/jdhamelink/Local/UNO_X/main.py", line 1, in <module>
     from kivy.app import App
   File "/Users/jdhamelink/Local/UNO_X/kivy_venv/lib/python3.8/site-packages/kivy/app.py", line 411, in <module>
     from kivy.base import runTouchApp, async_runTouchApp, stopTouchApp
   File "/Users/jdhamelink/Local/UNO_X/kivy_venv/lib/python3.8/site-packages/kivy/base.py", line 28, in <module>
     from kivy.clock import Clock
   File "/Users/jdhamelink/Local/UNO_X/kivy_venv/lib/python3.8/site-packages/kivy/clock.py", line 466, in <module>
     from kivy._clock import CyClockBase, ClockEvent, FreeClockEvent, \
 ImportError: dlopen(/Users/jdhamelink/Local/UNO_X/kivy_venv/lib/python3.8/site-packages/kivy/_clock.cpython-38-darwin.so, 0x0002): tried: '/Users/jdhamelink/Local/UNO_X/kivy_venv/lib/python3.8/site-packages/kivy/_clock.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_clock.cpython-38-darwin.so' (no such file), '/usr/lib/_clock.cpython-38-darwin.so' (no such file)
----------------
I couldn't really find any clear solutions to this problem. I think the core issue here is explained in the line "(mach-o file ... need 'arm64e')", but I don't know what this means and how to fix the issue. Can someone please help me?

Elliot Garbus

unread,
Nov 16, 2021, 8:31:41 AM11/16/21
to kivy-...@googlegroups.com

I don’t have an M1, but you will need to build from source.  I found this: https://stackoverflow.com/questions/69802436/install-kivy-on-macos-12-monterey-with-m1-chip/69958851

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/7865d68e-cab1-41a8-b27b-c7f3cfad0108n%40googlegroups.com.

 

Josef Hamelink

unread,
Nov 16, 2021, 11:37:32 AM11/16/21
to Kivy users support

Hi Elliot,

I think it worked. I did have to remove the venv folder inside my project directory thouh. Also, when running pytest kivy/tests in terminal, it said that 28 failed, 724 passed, 89 skipped in 34.89s. I hope this is good enough for now. If not I would love to hear what else might be the issue. In any case, when running my main.py function inside vscode, which is located outside of the cloned kivy repository folder, I am greeted with a lovely kivy window displaying a 'Hello world!'.

Thank you very much,

Kind regards,

Josef

Reply all
Reply to author
Forward
0 new messages