It seems that PyCharm & Kivy work on Windows (
https://groups.google.com/forum/#!searchin/kivy-users/pycharm/kivy-users/avoM81uLK0I/Dd500kxxbr0J). Unfortunately the same cannot be quite said off OSX.
I tried to mimic the behavior of the Kivy.app: it contains a script called "script" (/Applications/Kivy.app/Contents/Resources/script) which sets a few environment variables and then calls the system python with the application's main.py. So what I did in PyCharm:
Set global environement variables. This cannot be done in .bash_profile since PyCharm runs programs directly not in a shell. This means that env vars set in the bash_profile are ignored. The only option is to set them in /etc/launchd.conf. I know that I can set ewnv vars in the project, but that would mean entering them for each and every Kivy project. Launchctl does not use variable expansion, so one needs to use full env vars.
So /etc/launchd.conf contains:
setenv KIVY /Applications/Kivy.app/Contents/Resources
setenv LD_PRELOAD_PATH /Applications/Kivy.app/Contents/Resources/lib
setenv GST_PLUGIN_PATH /Applications/Kivy.app/Contents/Resources/lib/gst-plugins
setenv GST_PLUGIN_SCANNER /Applications/Kivy.app/Contents/Resources/lib/bin/gst-plugin-scanner
setenv GST_REGISTRY_FORK "no"
rebooted and verified that the vars are loaded correctly.
Then in PyCharm:
- Create a new project
- Copied the a Kivy demo app kivycatalog files to this folder
- Created a virtualenv 'kivyenv' based on the system python interpreter (2.7.2)
- Added
- /Applications/Kivy.app/Contents/Resources/kivy
- /Applications/Kivy.app/Contents/Resources/lib/sitepackages
to the virtualenv's Paths to put them on the PYTHONPATH.
- Set this virtualenv as the project python interpreter
- Run main.py
With the TouchTracer demo app and some other apps this seems to work! But with the demo apps KivyCatalog, RST_editor, audio it doesn't.
I get these errors:
[DEBUG ] [Atlas ] Load </Applications/Kivy.app/Contents/Resources/kivy/kivy/data/../data/images/defaulttheme.atlas>
[DEBUG ] [Atlas ] Need to load 1 images
[DEBUG ] [Atlas ] Load </Applications/Kivy.app/Contents/Resources/kivy/kivy/data/../data/images/defaulttheme-0.png>
[DEBUG ] [ImageImageIO] Load </Applications/Kivy.app/Contents/Resources/kivy/kivy/data/../data/images/defaulttheme-0.png>
arch: /Applications/Kivy.app/Contents/Resources/lib/bin/gst-plugin-scanner isn't executable
Process finished with exit code 137
In camera_puzzle I get:
[DEBUG ] [Cache ] register <kv.loader> with limit=500, timeout=60s
[INFO ] [Loader ] using a thread pool of 2 workers
Fatal Python error: (pygame parachute) Segmentation Fault
Process finished with exit code 134
So I'm progressing with Kivy+PyCharm but not quite there. Any ideas?
The second problem I have is that the approach outlined above seems to work more or less, I'd prefer to use the source version of Kivy with Homebrew installed python + other Kivy dependencies. I failed miserably. Has somebody tried the same?
Thanks all!
Marcel