Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
communitycreator

How to install the Kivy module in Python?

Chris Zichko

This shot will show you how to install the Kivy 2.0.0 module using pip in Python 3.8+. To start, I highly recommend creating a virtual environment before each use of Kivy. The reason for this is that there are some tools or modules that might be affected or affect the Kivy module and cause issues in the execution of your code.

If you are using Pycharm or another text editor that automatically creates a virtual environment, these next few steps are not needed. If you decide to skip making the virtual environment steps, go to Step 6.

Below are the steps to create a virtual environment and install Kivy with pip (Click the hints for screenshots) :

Step 1) Go to your desired directory.

Step 2) Type cmd in the url of the directory and press enter to open the command terminal.

Step 3) Type python -m pip install --upgrade pip setuptools virtualenv and press enter.

Linux users may have to use python3 instead of python in the command terminal and add a - -user flag in the commands outside of the virtual environment.

Step 4) Type python -m virtualenv kvenv.

Step 5) Type kvenv\Scripts\activate in the command terminal and press enter.

Wala! The virtual environment is now set up. For each use of the Kivy module outside of this directory, you will have to follow these steps again. However, if you are using a text editor, like Pycharm, that automatically creates a virtual environment, you may not have to.

Now, it’s time to use pip to install Kivy. Before we start using the commands to install Kivy, we must decide which version we need. There are three types kivy[base], kivy[base, media] and kivy[full]. Each type has different dependencies and is, ultimately, your preference. I tend to install kivy[full] for the projects I work on, so I will demonstrate here. However, installation with the other types is practically the same.

Step 6) The final step! Open the command terminal with (kvenv), type python -m pip install kivy[full], and press enter.

Note: If you look at Kivy’s website, you will see that it says to type “python -m pip install kivy[full] kivy_examples” instead of “python -m pip install kivy[full].” However, both ways will work.

Now, the Kivy module has been installed correctly inside a virtual environment that we created. In order to install the Kivy module for Mac and Windows, the same process should be followed.

This concludes how to install the Kivy module. To sum it up up, it is recommended that you create a virtual environment per the app or directory that you intend to use with Kivy. Once the virtual environment is created, you can install Kivy using pip. Then you will be ready to start coding your app with Kivy.

Have fun coding with Kivy!

RELATED TAGS

python
communitycreator
RELATED COURSES

View all Courses

Keep Exploring