Reputation: 101
After hours of trial an error, I hope, somebody can help me here.
I got my MacBook Air (M1, 2020) and want to use kivy for python-programming on it.
When I first bought the Laptop 3 month ago it took a lot of work to find a way to run kivy/ execute my kivy-code on it.
Finally, I ended up with the Kivy.app version which created [please excuse my limited understanding...] a Application, I could drag my python-files on or execute the files via the command line like kivy main.py
. The "usual" way of simply installing kivy via pip
did never work (as far as I understood because the presented wheel is not compatible with the M1-Chip).
Now, I upgraded my MacOS to Monterey, which crashed everything. I can't even give a lot of information about what's broken. when I try to drag files on the Kivy-Application simply nothing happens. Executing any file (even a simple print("Hello")
via the command line (like kivy main.py
) results in
kivy
/Applications/Kivy.app/Contents/Resources/venv/bin /Applications/Kivy.app/Contents/Resources /Applications/Kivy.app/Contents/Resources
ImportError: No module named site
Since I don't use any special setup, just the fresh updated MacOS in it's newest version and python (installed via homebrew and already reinstalled after updating the OS) I hope anyone with more understanding of the how's and why's than me already fixed this problem for him/her self and can enlighten me.
Upvotes: 2
Views: 3411
Reputation: 1516
I could run kivy on MacOS with M1 chip using rosetta 2.
Install rosetta 2
softwareupdate --install-rosetta
Start a terminal with rosetta. Right click to /Applications/iTerm or /Applicatins/Utilities/Terminal > Get Info > Open Using Rosetta
Create a fresh virtualenv. Install requirements
pip install kivy[base] kivy-examples
Run main.py (python main.py)
main.py
import kivy
kivy.require('2.0.0')
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
Upvotes: 1
Reputation: 1
Do you have Rosetta2 installed? I ask because Kivy.app
is an Intel Application and cannot work without that.
You need Homebrew and XCode, follow this guide:
brew install ffmpeg
After calling either:
python setup.py build_ext --inplace
...or your "make" command, you can call sudo make install
to build Kivy in your Python3 folder and remove the folder you downloaded previously.
If, during the build, you have an error due to missing cython, you need to install cython from the source; you can do this here.
P.S., I don't know how kivy.app works, but I use VSCode + Kivy CLI 2.1.0dev and when I launch the kivy app (with imported module of kivy); it launches with kivy, but when I try to launch the print('hello')
program, it only launches from the console (not with kivy).
Upvotes: 0