| by Arround The Web | No comments

How to Install Kivy on Raspberry Pi

Want to use your Raspberry Pi device for creating GUI applications? Install Kivy. It is an open-source Python framework that lets you develop cross-platform applications for mobile, Windows, macOS and Linux systems. Though Kivy uses the official Kivy language, it can be run efficiently on any Python IDE since it is already integrated with Python.

This article will teach you how to install and use Kivy on a Raspberry Pi system.

How to Install Kivy on Raspberry Pi

The Raspberry Pi doesn’t include the Kivy repository, thus, you won’t be able to install it directly from the “apt” command. However, you can follow the below-mentioned steps to install Kivy on the Raspberry Pi system easily.

Step 1: Clone Kivy Source Files from GitHub

First, you have to download the Kivy source files from GitHub websites from the following command:

$ git https://github.com/techcoder20/RPI-Kivy-Installer.git

Step 2: Navigate to Kivy Directory

Now, open the Kivy directory on the terminal through the following command:

$ cd Kivy-Raspberry-Pi-Installer

Step 3: Make the Installer File Executable

You have to make the Kivy installation file “install_kivy_rpi” executable using the following command:

$ chmod +x install_kivy_rpi

Step 4: Run the Kivy Installation File

To perform the Kivy installation, run the installer file through the below-given command:

$ sudo ./install_kivy_rpi

Wait till the Kivy installation is completed and once it’s done, you are good to use Kivy on the Raspberry Pi system.

Run Kivy on Raspberry Pi

To help you run and use Kivy on Raspberry Pi, let’s create a simple GUI application we call “kivy_file.py”. You can name the file on your own, and the file can be created in any Python IDE or a terminal using the “nano” editor.

Inside the file, add the following code:

import kivy

 

from kivy.app import App

from kivy.uix.button import Label

class Kivy(App):

 

       def build(self):
   
        return Label(text ="Your message")

 

helloKivy = Kivy()

helloKivy.run()

You can run the file from the terminal or IDE. In my case, I am executing the Kivy code through the terminal via the following command:

$ python3 <file_name>.py

In our case, the file name is “kivy_file.py”:

$ python3 kivy_file.py

The output will appear on the GUI windows with the Hello message, which ensures Kivy is successfully running on the Raspberry Pi system. This way, you can write your code and start creating GUI applications on your Raspberry Pi system with Kivy.

Conclusion

Kivy is a Python framework that helps you create GUI applications for different platforms, including mobile, Windows, macOS and Linux. You can install it by downloading the source files from the GitHub website and then executing the installation files to install Kivy on a Raspberry Pi system successfully. After the installation, you can get help from a simple hello message code discussed above to learn how to run Kivy on Raspberry Pi. You can write your code and start creating a GUI application on your system.

Share Button

Source: linuxhint.com

Leave a Reply