Skip to content

Using Kivy with an existing Python installation on Windows (64 or 32 bit)

dessant edited this page Nov 30, 2015 · 5 revisions

DEPRECATED: Kivy wheels are available starting version 1.9.1.

As an alternative to downloading the kivy distribution zip file, you can install the kivy requirements into an existing 32 or 64 bit Python installation.

An unofficial pre-built binary windows installer is available at http://www.lfd.uci.edu/~gohlke/pythonlibs/#kivy

Otherwise, you can follow these instructions to build kivy from source:

For this example we'll assume you have Python installed in C:\dev\python27:

  1. You need a MinGW installation. You can use the MinGW directory included in the kivy distribution or download a fresh MinGW. If you're compiling for 64 bit you'll need to the download the 64 bit MinGW (see here for how to setup a 64 bit mingw).

  2. If you want to use gstreamer, copy it from the kivy distribution directory.

  3. Get the kivy.bat file from the kivy distribution, or alternatively set the path and other environmental variables as in the kivy.bat file in order to have a permanent setup. You'll have to execute the following instructions from this environment.

    You'll need to edit the paths first to point to the correct python and MinGW locations. If you started with a clean MinGW installation you'll also have to add to the path the location of make.exe if you will be doing any kivy development.

  4. Download and install distutils and pip. You can install both using the ez_setup.py and get_pip.py files from http://www.pip-installer.org/en/latest/installing.html.

  5. In C:\dev\python27\Lib\distutils create a empty distutils.cfg file. In the file type:

    [build]
    compiler=mingw32
    
  6. Download and install cython by typing:

    pip install cython
    
  7. Download Glew 1.5.7 from http://sourceforge.net/projects/glew/files/glew/. Install the Glew files into the following locations:

    glew32.dll -> C:\dev\python27
    glew32.dll -> MinGW\lib
    glew32.lib -> MinGW\lib
    glew32s.lib -> MinGW\lib
    glew.h -> MinGW\include\GL
    glxew.h -> MinGW\include\GL
    wglew.h -> MinGW\include\GL
    

    If you get errors when installing kivy such as GL/glew.h: No such file or directory, which is likely to happen with the 64 bit mingw, you'll need to copy the GL directory and its contents into python27/include and the *.dll and *.lib files from above into python27/libs. If you still get errors then type the following to generate the .a file:

    cd C:\dev\Python27\libs
    rename glew32.lib old_glew32.lib
    rename glew32s.lib old_glew32s.lib
    gendef glew32.dll
    dlltool --dllname glew32.dll --def glew32.def --output-lib libglew32.a
    
  8. Download and install the precompiled Pygame 1.9.2 binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame.

  9. Finally, to install the latest kivy, type:

    pip install https://github.com/kivy/kivy/zipball/master
    

    Alternatively instead of the githup zipball you can point to a specific kivy zip file. Also, if you have a development version of kivy and want to continue working on it while still installing it you can use the pip --editable switch e.g.:

    pip install --editable C:\dev\kivy
    

    This will put a link in the site-packages directory pointing to your kivy source, so any changes in the source will be reflected in the install. See here for more details: http://pythonhosted.org/setuptools/setuptools.html#development-mode.

Clone this wiki locally