Search code examples
pythonwindowspython-2.7pycharmkivy

How to configure Python Kivy for PyCharm on Windows?


I'm having trouble getting Kivy to work with PyCharm on Windows 7. I've managed to add most of the external libraries through File > Settings > Python interpreters > Paths Tab.

I'm using the Kivy version of Python. When I run a Kivy app that works fine with using the [right click > send to > kivy.bat] method in PyCharm, it gives me this error:

Failed modules
Python 2.7.3 (C:/Python27/python.exe) 
_imagingtk
dde
gtk._gtk
pangocairo
Generation of skeletons for the modules above will be tried again when the modules are updated or a new version of generator is available

I think that the problem might be something to do with cython, as my file fails to recognise the kivy.properties file, which is of the Cython *.pxd format.


Solution

  • This Kivy's Wiki page Setting Up Kivy with various popular IDE's has a better answer and detail commands. It is copied below with added information for Pycharm 3.4.

    Go to your unzipped Kivy folder, create a symbol link for "kivy.bat" pointing to "python.bat" in the same directory (mklink python.bat kivy.bat).

    Add 2 new Python interpreters in PyCharm.

    • Bootstrapper: Choose the earlier created "python.bat" from the Kivy package folder.
    • Project Interpreter: Choose the "python.exe" from the Python subdirectory in the Kivy package folder.

    For the project interpreter, add a path to the "kivy" directory directly contained in the Kivy package folder. In PyCharm 3.4, the path tab is hidden in a sub menu. In Project Interpreter, click the tool icon next to the interpreter dropdown list, click more... (the last one), in the list of all project interpreters, select Run-Configuration Interpreter, on the right side there are five icons (+, -, edit, virtual env, and path), click path to add the Kivy sub-directory in unzipped Kivy folder.

    Save all settings and ignore warnings about "Invalid output format". Make sure that the project interpreter is set to our earlier created configuration.

    Create a new run configuration and set the Python interpreter to our earlier created bootstrapper.

    Simply run the configuration to execute your Kivy application