I switched from various Eclipse flavours (vanilla, CDT) to IntelliJ IDEA Ultimate Edition almost a year ago and never looked back. The IDE is not only suitable for Java development, but for Python projects as well and I would like to use it when developing Python scripts that ought to run on my Raspberry Pi. Programming directly on the Raspberry Pi using an IDE can be quite cumbersome, since modern IDEs run abysmally due to the CPU and memory limitations of the Pi and unless your a vi guru, you won't have fun with that editor either. I needed a way to write my Python scripts on my development machine, while programming against the Python SDK on the Pi (with all its installed libraries like RPi.GPIO and pygame) remotely. Easy deployment to the Pi would be a benefit, but not necessarily a must-have, since I could live with a simple scp-based solution that copies over project files recursively.

Turns out that IDEA is able to fulfill both requirements to full extent, easing Python development for the Pi tremendously. This short article will guide you through the configuration of a remote Python interpreter and the setup of an module-based deployment to your Pi.

Installing the Python plugin

The Python plugin for IDEA is built from the same codebase as JetBrains PyCharm. So if you are a PyCharm user, this guide applies to your IDE as well, although accessing some menus might be a bit different.

  1. Open up the Settings dialog and search for Plugins located in category IDE settings.
  2. Click on Browse Repositories and filter the list of available plugins by Python.
  3. Select the Python plugin, right-click on it and select Download and Install.

The Python plugin will be downloaded and installed without further user interaction. Once IDEA completed that task, hit apply and close the Settings dialog. IDEA will ask you to restart the IDE.

Configuring the remote Python SDK

  1. Turn on your Raspberry Pi. I assume that your Pi is connected to your local network.
  2. Open up the Configure SDK. You need to create a new or open an existing Python project for that. If you created a new Python project, IDEA will ask you to select an existing Python SDK or configure a new one. This will open the Configure SDK dialog. If you opened an existing project, select Project Settings followed by SDKs to open up the Configure SDK dialog as well.
  3. Click on Add New SDK and select Python SDK. Doing so will yield further choices: Select Remote....
  4. This will open the Configure Remote Python Interpreter dialog. Fill in the connection details. You might end up with something similar to the following screenshot (depending on your authentication mechanism).

    Configuration of the remote Python SDK

  5. Click on Test connection... to verify that the configuration is working.

  6. Apply the settings. IDEA will do the necessary setup for you.

Configuring the remote deployment to the Pi for your project

  1. Select Tools from the menu, followed by Deployment and Configuration.
  2. Add a server by clicking on the green '+' in the top-left corner.
  3. Give the server a name and select SFTP as connection type.
  4. Fill in the connection details (as done before) in tab Connection. Test the connection before applying your changes to the configuration.

    Configuration of connection details

  5. Select tab Mappings. The local path to your project is already filled in. Add the deployment path on the server. Please note that while the local path is absolute, the deployment is relative to the path you specified as Root Path in the Connection tab. In this example, IDEA would deploy the files to folder /home/pi/python/remote-sdk. You do not need to fill out the web path, unless you are programming a web-based solution and require a web deployment as well.

    Configuration of folder mappings

  6. Hit Apply to save your configuration.

Selecting ToolsDeploymentUpload to will open up a small dialog which allows you to select the deployment server. After this, IDEA uploads your project (or selected files) to that server, regarding the directory mappings you configured beforehand. To speed up the deployment process, I encourage you to add a keyboard shortcut for that kind of operation. For instance, I mapped the Deploy to action to CTRT+SHIFT+K.

And that's it! With this configuration in place, you are able to comfortably write Python scripts against the Python SDK on the Raspberry Pi, deploy to it and run or debug your scripts remotely.

Hi there! I'm Markus!

I'm an independent freelance IT consultant, a well-known expert for Apache Kafka and Apache Solr, software architect (iSAQB certified) and trainer.

How can I support you?

GET IN TOUCH