Kivy, Eclipse and PyDev (also PyPy)
Pergunta
According to this post: https://groups.google.com/forum/?fromgroups#!topic/kivy-users/n7c3thksnzg, it is possible to use Eclipse as an IDE for Kivy through PyDev. However, I didn't understand the instructions. Can anyone please elaborate on how to connect Kivy with Eclipse.
Note: I'm on a Windows machine. Also, is it possible to use PyPy instead of the Python Interpreter?
Thanks~!
Solução
Using Kivy with Pydev on Windows xp/7
- Under Window/Preferences/PyDev/Interpreter-Python add a new interpreter pointing to the python executable which ships with kivy portable
- add kivy package folder under libraries tab (still in Python Interpreters Prefs section making sure the kivy python interpreter is selected)
In Environment tab, add the following three key-value pairs: (assumptions: kivy root is c:\kivy)
GST_REGISTRY = c:\kivy\gstreamer\registry.bin
GST_PLUGIN_PATH = c:\kivy\gstreamer\lib\gstreamer-0.10
PATH = c:\kivy;c:\kivy\Python;c:\kivy\gstreamer\bin;c:\kivy\MinGW\bin;%PATH%
When creating a new project intended to use kivy, just specify the appropriate interpreter and you should be ready to go
Outras dicas
I think it's just pointing that:
The PATH, GST_PLUGIN_PATH, GST_REGISTRY environment variables must be set (which you can actually do on the command line and then start up eclipse from that command line, or set in the interpreter configuration in the environment tab): http://pydev.org/manual_101_interpreter.html.
Kivy must be added to the PYTHONPATH somehow. If you want, you can add it only to a project (as pointed in the post -- see: http://pydev.org/manual_101_project_conf2.html) or to the actual interpreter configuration if more projects will share that: http://pydev.org/manual_101_interpreter.html.
After following instructions above I was still having problems with imports not found. I found I had to open my project's properties in Eclipse and under "PyDev - PYTHONPATH" add my kivy directory, e.g. C:\Kivy141\kivy
As of kivy 1.9.0, PATH must also include c:\kivy\SDL2\bin or else when trying to run kivy will throw an error and fail at opening a window. I Think I read that kivy no longer use PyGame and shifted to SDL2 since the answer posted in april 2012.
I am using Windows 7 x64 with Eclipse Mars(release 4.5.1).
The steps that worked for me(very close to Rabih answer):
1. I copied Kivy 1.9.0 on my local machine from here
2. I renamed the kivy.bat file to python.bat(this step can be ignored)
3. Eclipse->Window->Preferences->PyDev->Interpreters->Python Interpreter->New
and added the python.bat file as interpreter. After doing this the interpreter should look like in the image:
4. In the Environement tab add the 3 keys everybody mentioned:
GST_REGISTRY = c:\kivy\gstreamer\registry.bin
GST_PLUGIN_PATH = c:\kivy\gstreamer\lib\gstreamer-0.10
PATH = c:\kivy;c:\kivy\Python;c:\kivy\gstreamer\bin;c:\kivy\MinGW\bin;%PATH%
5. Use the interpreter that you just created in your project. Note that a default one will be selected if you don't specify the one you created
Using Eclipse IDE with Kivy and Pydev on OS X
- Type
which ivy
in the terminal and locate the executable (it should be /usr/local/bin/kivy) - Then choose Preferences from Eclipse menu and navigate to PyDev -> Interpreters -> Python Interpreter.
- Open the Select Interpreter dialog by clicking on the New... button (1) on the right.
- Fill the name of interpreter (kivy) in the Interpreter Name field (2)
- Fill the identified path (/usr/local/bin/kivy) in the Interpreter Executable field
- Press OK and wait till the process will be done.
- Do not forget to change interpreter settings in your project. You can do it by right click on your project in the Package Explorer under the PyDev - Interpreter/Grammar page.