- Flash SD Card (use official Raspbian Imager -> saves you the hassle to Setup Wifi, Pi User, etc. headless)
- Insert and Boot
- Run
sudo raspi-config
and expand the FileSystem - Update with
sudo apt-get update sudo apt-get upgrade
- If asked for what to do with modified sshd config, choose:
keep the local version currently installed
- Reboot
- Install Git
sudo apt-get install git
- Run PyEnv Installer Script and Setup Environment
curl https://pyenv.run | bash echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc exec "$SHELL"
- Install Prerequisites for Python 3.9 Installation through PyEnv
sudo apt-get install build-essential zlib1g-dev libffi-dev libssl-dev libbz2-dev libreadline-dev libsqlite3-dev liblzma-dev
- Install Python 3.9
pyenv install 3.9.13
- Create virtualenv for development
pyenv virtualenv 3.9.13 venv39
- Install Prerequisites for Kivy
sudo apt install pkg-config libgl1-mesa-dev libgles2-mesa-dev \ libgstreamer1.0-dev \ gstreamer1.0-plugins-{bad,base,good,ugly} \ gstreamer1.0-alsa libmtdev-dev \ xclip xsel libjpeg-dev
- Install Prerequisites for SDL2
sudo apt-get install libfreetype6-dev libgl1-mesa-dev libgles2-mesa-dev libdrm-dev libgbm-dev libudev-dev libasound2-dev liblzma-dev libjpeg-dev libtiff-dev libwebp-dev git build-essential sudo apt-get install gir1.2-ibus-1.0 libdbus-1-dev libegl1-mesa-dev libibus-1.0-5 libibus-1.0-dev libice-dev libsm-dev libsndio-dev libwayland-bin libwayland-dev libxi-dev libxinerama-dev libxkbcommon-dev libxrandr-dev libxss-dev libxt-dev libxv-dev x11proto-randr-dev x11proto-scrnsaver-dev x11proto-video-dev x11proto-xinerama-dev
- Install SDL2
Output of
wget https://libsdl.org/release/SDL2-2.0.22.tar.gz tar -zxvf SDL2-2.0.22.tar.gz pushd SDL2-2.0.22 ./configure --enable-video-kmsdrm --disable-video-opengl --disable-video-x11 --disable-video-rpi
./configure ...
should be someting like:
Now Compile and Install... Enabled modules : atomic audio video render events joystick haptic hidapi sensor power filesystem threads timers file misc locale loadso cpuinfo assembly Assembly Math : Audio drivers : disk dummy oss alsa(dynamic) sndio(dynamic) Video drivers : dummy kmsdrm(dynamic) opengl_es1 opengl_es2 vulkan wayland(dynamic) Input drivers : linuxev linuxkd Enable virtual joystick APIs : YES Using libsamplerate : NO Using libudev : YES Using dbus : YES Using ime : YES Using ibus : YES Using fcitx : YES
make -j4 sudo make install popd
- Install SDL2_image
wget https://libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.tar.gz tar -zxvf SDL2_image-2.0.5.tar.gz pushd SDL2_image-2.0.5 ./configure make -j4 sudo make install popd
- Install SDL2_mixer
wget https://github.com/libsdl-org/SDL_mixer/releases/download/release-2.6.1/SDL2_mixer-2.6.1.tar.gz tar -zxvf SDL2_mixer-2.6.1.tar.gz pushd SDL2_mixer-2.6.1 ./configure make -j4 sudo make install popd
- Install SDL2_ttf
wget https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.20.0/SDL2_ttf-2.20.0.tar.gz tar -zxvf SDL2_ttf-2.20.0.tar.gz pushd SDL2_ttf-2.20.0 ./configure make -j4 sudo make install popd
- Update dynamic libraries cache
sudo ldconfig -v
-
Change into a Project Directory
-
Set Python Env to Virtualenv created above
pyenv local venv39
-
Upgrade Python libraries
python -m pip install --upgrade pip setuptools
-
Install Kivy 2.1.0 from source
python -m pip install "kivy[base] @ https://github.com/kivy/kivy/archive/023bd79b90f9831b45bb8eb449346648aa5fe5f8.zip"
-
Test Everything with a simple HelloWorld Program:
main.py
from kivy.app import App from kivy.uix.label import Label class MainApp(App): def build(self): return Label(text="Hello, World") MainApp().run()
-
Run it with
python main.py
Some Notes
/boot/config.txt
and changevc4-kms-v3d
tovc4-fkms-v3d
raspi-config
) and egl_rpi Kivy Backend