|
- On the host system (Windows/Mac/Linux) download and install latest versions of
- |
PuTTY from www.chiark.greenend.org.uk |
- |
Python 2.7 from www.python.org (not used for remote development) |
- |
PyCharm Professional version from www.jetbrains.com (request student or academic discount)
(the Community and Edu version do not support remote interpreters) |
- Establish a TCP/IP link between the host system and the Raspberry Pi and start a SSH terminal session with PuTTY
- At the Raspberry Pi, create a new folder for your Python programs, e.g. /home/pi/scripts
- Start PyCharm and at bottom-right click Configure | Settings
|
|
|
- Select Project Interpreter and click the wheel. Select Add Remote
- Select SSH Credentials and fill out the form. Username is pi and password raspberry
- Confirm that you want do continue. Click OK to accept the configuration. The PyCharm helper files (skeletons, modules, etc.) will be downloaded to the Raspberry Pi.
- Click Create New Project and select Pure Python. Enter a location where to store the files on the development system, e.g. d:\mycharm (Windows)
- Select File | New | Python File and enter a file name, e.g. Ex1. Edit any short Python script, e.g. "print "Hello Raspberry Pi"
- Click File | Settings | Deployment and Add a server with SFTP protocol
- In the Connection dialog, fill out the SFTP host, Root path (/home/pi), User name (pi) and Password fields (raspberry
- In the Mappings dialog, enter /scripts as Deployment path
- Right click at Ex1.py and select Upload to apluraspi. You should get a confirmation message for the file transfer
|
|
|
- Right click at Ex1.py and select Run 'Ex1'. You should get the captured output to stdout in bottom area of the PyCharm window
- As you see the script is remotely run by the command /usr/bin/python -u /home/pi/scripts /Ex1.py. For most Raspberry Pi programs the script must be executed with sudo permission. To achieve this, create a Linux script pyrun (or any other name) in /usr/bin/ (with execute permission) as shown to the right. (The -Qnew option requests floating point division. The file is provided in the RaspiBrick firmware distribution.)
#! /bin/sh
sudo python2.7 -Qnew $*
- Under File | Settings | Project Interpreter click the wheel and select Add Remote.At the line Python interpreter path, click the right [...] button. A dialog opens where you can select the pyrun script.
- To check whether you are successful, right click at Ex1.py and select Run 'Ex1'. You should see that now the script is indeed executed by pyrun.
|