2014-02-18 12:53:15 +00:00
.. _installation_rpi:
Installation on Raspberry Pi
============================
2020-11-28 08:36:39 +00:00
To install Kivy on the RPi using `` pip `` , please follow the main :ref: `installation guide<installation-canonical>` .
Installation components
-----------------------
Following, are additional information linked to from some of the steps in the
main :ref: `pip installation guide<installation-canonical>` , specific to the RPi.
.. _install-python-rpi:
Installing Python
^^^^^^^^^^^^^^^^^
Python and python-pip must be installed from the package manager:
Raspbian Jessie/Stretch/Buster
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using apt::
sudo apt update
sudo apt install python3-setuptools git-core python3-dev
Arch Linux ARM
~~~~~~~~~~~~~~
Images to use::
http://raspex.exton.se/?p=859 (recommended)
https://archlinuxarm.org/
Using pacman::
sudo pacman -Syu
# Note: python-setuptools needs to be installed through pacman or it will result with conflicts!
sudo pacman -S python-setuptools
# Install pip from source
wget https://bootstrap.pypa.io/get-pip.py
# or curl -O https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
.. _install-source-rpi:
Source installation Dependencies
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To install Kivy from source, please follow the installation guide until you reach the
:ref: `Kivy install step<kivy-source-install>` and then install the dependencies below
before continuing.
Raspbian Jessie/Stretch/Buster
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using apt::
sudo apt update
sudo apt install pkg-config libgl1-mesa-dev libgles2-mesa-dev \
libgstreamer1.0-dev \
gstreamer1.0-plugins-{bad,base,good,ugly} \
gstreamer1.0-{omx,alsa} libmtdev-dev \
xclip xsel libjpeg-dev
And then install SDL2 using either of the two options below depending on whether you
will be running Kivy from a headless or desktop environment:
2015-03-30 19:24:09 +00:00
2020-11-28 08:36:39 +00:00
Raspberry Pi 1-4 Desktop environment
***** ***** ***** ***** ***** ***** ***** *
2014-02-18 12:53:15 +00:00
2020-11-28 08:36:39 +00:00
If you have installed Raspbian with a desktop i.e. if your Raspberry Pi boots into a desktop environment
then install SDL2 from apt::
2019-12-21 20:29:04 +00:00
2020-11-28 08:36:39 +00:00
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
Raspberry Pi 4 headless installation on Raspbian Buster
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** *****
If you run Kivy from the console and not from a desktop environment, you need to compile SDL2
from source, as the one bundled with Buster is not compiled with the `` kmsdrm `` backend,
so it only works under `` X11 `` .
Install requirements::
2019-12-21 20:29:04 +00:00
2020-03-13 15:15:45 +00:00
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
2019-12-21 20:29:04 +00:00
2020-11-28 08:36:39 +00:00
Install SDL2::
2019-12-21 20:29:04 +00:00
2020-03-13 15:15:45 +00:00
wget https://libsdl.org/release/SDL2-2.0.10.tar.gz
tar -zxvf SDL2-2.0.10.tar.gz
pushd SDL2-2.0.10
./configure --enable-video-kmsdrm --disable-video-opengl --disable-video-x11 --disable-video-rpi
make -j$(nproc)
sudo make install
popd
2019-12-21 20:29:04 +00:00
2020-11-28 08:36:39 +00:00
Install SDL2_image::
2019-12-21 20:29:04 +00:00
2020-03-13 15:15:45 +00:00
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 -j$(nproc)
sudo make install
popd
2014-02-18 12:53:15 +00:00
2020-11-28 08:36:39 +00:00
Install SDL2_mixer::
2019-12-21 20:29:04 +00:00
2020-03-13 15:15:45 +00:00
wget https://libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.4.tar.gz
tar -zxvf SDL2_mixer-2.0.4.tar.gz
pushd SDL2_mixer-2.0.4
./configure
make -j$(nproc)
sudo make install
popd
2019-12-21 20:29:04 +00:00
2020-11-28 08:36:39 +00:00
Install SDL2_ttf::
2019-12-21 20:29:04 +00:00
2020-03-13 15:15:45 +00:00
wget https://libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.15.tar.gz
tar -zxvf SDL2_ttf-2.0.15.tar.gz
pushd SDL2_ttf-2.0.15
./configure
make -j$(nproc)
sudo make install
popd
2019-12-21 20:29:04 +00:00
2020-11-28 08:36:39 +00:00
Make sure the dynamic libraries cache is updated::
2019-12-21 20:29:04 +00:00
2020-03-13 15:15:45 +00:00
sudo ldconfig -v
2019-12-21 20:29:04 +00:00
2020-11-28 08:36:39 +00:00
If you are getting output similar to this when running your app::
2020-03-14 19:40:55 +00:00
[INFO ] GL: OpenGL vendor <b'VMware, Inc.'>
[INFO ] GL: OpenGL renderer <b'llvmpipe (LLVM 9.0.1, 128 bits)'>
2020-11-28 08:36:39 +00:00
Then it means that the renderer is **NOT** hardware accelerated. This can be fixed by adding your user to the render group::
2020-03-14 19:40:55 +00:00
sudo adduser "$USER" render
2020-11-28 08:36:39 +00:00
You will then see an output similar to this::
2020-03-14 19:40:55 +00:00
[INFO ] GL: OpenGL vendor <b'Broadcom'>
[INFO ] GL: OpenGL renderer <b'V3D 4.2'>
2015-10-23 22:37:36 +00:00
2020-11-28 08:36:39 +00:00
Arch Linux ARM
~~~~~~~~~~~~~~
2017-10-15 16:06:36 +00:00
2020-11-28 08:36:39 +00:00
Using pacman::
2017-10-15 16:06:36 +00:00
2020-11-28 08:36:39 +00:00
sudo pacman -S sdl2 sdl2_gfx sdl2_image sdl2_net sdl2_ttf sdl2_mixer
2015-10-23 22:37:36 +00:00
2020-01-11 00:21:35 +00:00
Raspberry Pi window provider and GL backend
-------------------------------------------
By default the Raspberry Pi 1-3 will use the `` egl_rpi `` window provider and the `` gl `` GL backend.
Since the `` egl_rpi `` window provider is not available on the Raspberry Pi 4 it uses the `` sdl2 `` window provider and the `` sdl2 `` GL backend by default.
The window provider and GL backend can be changed at runtime by setting the `KIVY_WINDOW`_ and `KIVY_GL_BACKEND`_ environmental variables.
The table below shows the supported combinations of window provider and GL backend on the 4 platforms:
+------------------------------------+-----------------------------------+-------+-------+-------+-------+
| Window provider (`KIVY_WINDOW`_ \=) | GL backend (`KIVY_GL_BACKEND`_ \=) | RPi 1 | RPi 2 | RPi 3 | RPi 4 |
+====================================+===================================+=======+=======+=======+=======+
| sdl2 | sdl2/gl | y | y | y | y |
+------------------------------------+-----------------------------------+-------+-------+-------+-------+
| x11 | gl | y | y | y | y |
+------------------------------------+-----------------------------------+-------+-------+-------+-------+
| egl_rpi | gl | y | y | y | n |
+------------------------------------+-----------------------------------+-------+-------+-------+-------+
.. _KIVY_WINDOW: https://kivy.org/doc/stable/guide/environment.html#restrict-core-to-specific-implementation
.. _KIVY_GL_BACKEND: https://kivy.org/doc/stable/guide/environment.html#restrict-core-to-specific-implementation
2015-09-14 11:28:29 +00:00
Change the default screen to use
--------------------------------
You can set an environment variable named `KIVY_BCM_DISPMANX_ID` in order to
change the display used to run Kivy. For example, to force the display to be
HDMI, use::
2019-12-21 20:29:04 +00:00
KIVY_BCM_DISPMANX_ID=2 python3 main.py
2015-09-14 11:28:29 +00:00
2016-06-19 05:51:40 +00:00
Check :ref: `environment` to see all the possible values.
2014-02-18 12:53:15 +00:00
2015-09-22 13:32:48 +00:00
Using Official RPi touch display
--------------------------------
If you are using the official Raspberry Pi touch display, you need to
configure Kivy to use it as an input source. To do this, edit the file
`` ~/.kivy/config.ini `` and go to the `` [input] `` section. Add this:
::
mouse = mouse
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput
For more information about configuring Kivy, see :ref: `configure kivy`