Setting up Pycharm on OSX (older versions) - darkopevec/kivy GitHub Wiki
Installing PyCharm for Kivy (older versions)
This page stores instructions for installing older version of PyCharm and Kivy, kept for the sake of completeness. These version are no longer supported and we strongly recommend you use the latest versions of both. Instruction for the current versions can be found here.
Setting up Kivy 1.8 with PyCharm 4 on OS/X
-
Open your project in PyCharm
-
Run -> Edit Configurations -> Environment Variables
-
Add entries for the several required variables.
-
If you have a non-standard installation, you can get the updated environment variables by running the kivy script interactively:
Setting up Kivy 1.9.0 with PyCharm 4.5 EAP on OS X 10.10.3
-
Install Kivy 1.9.0
We assume you have copied the
Kivy.app
folder as found in Kivy-1.9.0-rev3-osx.dmg into the/Applications
folder. -
Make kivy known to PyCharm
Add a link to the kivy package in the
site-packages
folder of the interpreter that kivy uses:
cd /Applications/Kivy.app/Contents/Resources/venv/lib/python2.7/site-packages
ln -s /Applications/Kivy.app/Contents/Resources/kivy/kivy kivy
PyCharm scans the site-packages
folder to help you with auto-complete.
We'll check this in a later step.
-
Configure a Project Interpreter
-
Start PyCharm.
-
Close any project you may have open (
File->Close Project
). -
At the bottom of the Welcome screen, choose
Configure -> Preferences
. (Alternatively, pressCMD-,
). -
In the Default Preferences window, choose
Default Project -> Project Interpreter
.
Click theclog
icon in the upper right corner, and in the drop-down list, chooseMore...
In the Project Interpreters window, click theplus
icon, and in the drop-down list, chooseAdd Local
. -
In the Select Python Interpreter window, delete the path of the currently selected python interpreter (in my case, this was /usr/bin/python) and navigate to (or copy that path into the address bar):
/Applications/Kivy.app/Contents/Resources/python
-
Click
OK
to close the Select Python Interpreter window.
Optional: give the interpreter a nicer name, by clicking thepencil
icon in the Project Interpreters window: in the Edit Python Interpreter window'sName
field, add 'KIVY' between 'Python' and '2.7.6'. This will make the kivy interpreter more easily recognizable later on. -
Click
OK
to close the Project Interpreters window. -
Click
Apply
at the bottom of the Default Preferences window. -
Click
OK
to close the Default Preferences window.
-
-
Set the interpreter of your project
- Either open a project you already created, or create a new one. Here, I will create a new one (a Pure Python project).
- In the pane that appears after choosing
New Project
, in the drop-down list that accompanies theInterpreter
field, select the KIVY interpreter we created in the preceding step.
Click theCreate
button. - If you chose to open an existing project: open up the
PyCharm-EAP->Preferences...
menu in the main menu (or useCMD-,
); in the Preferences window chooseProject: *your_existing_project*->Project Interpreter
and use the drop-down list to select the KIVY interpreter. ClickApply
and then clickOK
.
-
Check that auto-complete works
Create a new Python file in your project and start typing, e.g. let's begin with an import:
import kiv
and note the pop-up. Yay! -
Configure a Run/Debug configuration
From the main menu bar of PyCharm, choose
Run->Edit Configurations...
-
In the Run/Debug Configurations, click the
plus
icon (or, use the keyboard shortcutCMD-N
), and choosePython
from the drop-down list to create a new configuration.
Note that thePython interpreter
field already shows the KIVY interpreter filled in. -
Fill out the
Name
,Script
, and other fields you would normally need to fill. -
Click the
ellipsis
icon (...) that accompanies theEnvironment variables
field. -
In the Environment Variables field, use the
plus
icon orCMD-N
keyboard short-cut to add the following environment variables -- as found in/Applications/Kivy.app/Contents/Resources/script
-- (you can copy the whole block and paste it with theclipboard
icon):
-
PYTHONPATH=/Applications/Kivy.app/Contents/Resources/kivy:${PYTHONPATH}
GST_PLUGIN_SCANNER=/Applications/Kivy.app/Contents/Resources/gst-plugin-scanner
GIO_EXTRA_MODULES=/Applications/Kivy.app/Contents/Frameworks/GStreamer.framework/Versions/Current/lib/gio/modules
LD_PRELOAD_PATH=/Applications/Kivy.app/Contents/Resources/lib
GST_PLUGIN_SYSTEM_PATH=/Applications/Kivy.app/Contents/Frameworks/GStreamer.framework/Versions/Current/lib/gstreamer-1.0
KIVY_HOME=/Applications/Kivy.app/Contents/Resources/.kivy
GTK_PATH=/Applications/Kivy.app/Contents/Frameworks/GStreamer.framework/Versions/Current
DYLD_FALLBACK_LIBRARY_PATH=/Applications/Kivy.app/Contents/Resources/lib
GST_REGISTRY=/Applications/Kivy.app/Contents/Resources/gst.registry
Note: because of the link we created in the site-packages
folder, I think the PYTHONPATH adaptation is not needed (need to check)
Note: I filed an issue with respect to seemingly non-existing ${SCRIPT_PATH}/lib
folder usage
Note: I'm not sure if KIVY_HOME
is somehow overridden to be ${USER}/.kivy
where I find my Kivy configuration settings and log files.
* Finally click the `Apply` button and then the `OK` button in the _Run/Debug Configurations_ window.