kivy Installation & Setup


Example

Windows

There are two options how to install Kivy:

First ensure python tools are up-to-date.

python -m pip install --upgrade pip wheel setuptools

Then install the basic dependencies.

python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew

Although Kivy already has providers for audio & video, GStreamer is required for more advanced stuff.

python -m pip install kivy.deps.gstreamer --extra-index-url https://kivy.org/downloads/packages/simple/

To make it simpler, <python> in the following text means a path to the directory with python.exe file.

  1. Wheel

    The wheel package provides compiled Kivy, but with removed cython source components, which means the core code can't be recompiled using this way. Python code, however, is editable.

    The stable version of Kivy is available on pypi.

    python -m pip install kivy
    

    The latest version from the official repository is available through nightly-built wheels available on google drive. Visit the link in docs matching your python version. After a proper wheel is downloaded, rename it to match the formatting of this example and run the command.

    python -m pip install C:\Kivy-1.9.1.dev-cp27-none-win_amd64.whl
    
  2. Source

    There are more required dependencies needed to install Kivy from source than using the wheels, but the installation is more flexible.

    Create a new file in <python>\Lib\distutils\distutils.cfg with these lines to ensure a proper compiler will be used for the source code.

    [build]
    compiler = mingw32
    

    Then the compiler is needed. Either use some you already have installed, or download mingwpy. The important files such as gcc.exe will be located in <python>\Scripts.

    python -m pip install -i https://pypi.anaconda.org/carlkl/simple mingwpy
    

    Don't forget to set environment variables to let Kivy know what providers it should use.

    set USE_SDL2=1
    set USE_GSTREAMER=1
    

    Now install the additional dependencies required for the compilation.

    python -m pip install cython kivy.deps.glew_dev kivy.deps.sdl2_dev
    python -m pip install kivy.deps.gstreamer_dev --extra-index-url https://kivy.org/downloads/packages/simple/
    

    Check Paths section to ensure everything is set properly and install Kivy. Choose one of these options:

    python -m pip install C:\master.zip
    python -m pip install https://github.com/kivy/kivy/archive/master.zip
    

Paths

Kivy needs an access to the binaries from some dependencies. This means the correct folders have to be on the environment's PATH variable.

set PATH=<python>\Tools;<python>\Scripts;<python>\share\sdl2\bin;%PATH%

This way Python IDLE IDE can be included to the path with <python>\Lib\idlelib;. Then write idle into console and IDLE will be ready to use Kivy.

Simplify it

To avoid repetitive setting of environment variables either set each necessary path this way or make a batch(.bat) file with these lines placed into <python>:

set PATH=%~dp0;%~dp0Tools;%~dp0Scripts;%~dp0share\sdl2\bin;%~dp0Lib\idlelib;%PATH%
cmd.exe

To run Kivy project after installation run cmd.exe or the batch file and use python <filename>.py

installation on Ubuntu

For install kivy on ubuntu with kivy example open terminal and run following command

First add ppa

 sudo add-apt-repository ppa:kivy-team/kivy

For install kivy

 sudo apt-get install python-kivy

For install kivy examples

 sudo apt-get install python-kivy-example