element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Sci Fi Your Pi
  • Challenges & Projects
  • Design Challenges
  • Sci Fi Your Pi
  • More
  • Cancel
Sci Fi Your Pi
Blog Meditech Annex II - Python development lifecycle on Raspberry PI
  • Blog
  • Forum
  • Documents
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: balearicdynamics
  • Date Created: 9 Aug 2015 5:12 PM Date Created
  • Views 1259 views
  • Likes 2 likes
  • Comments 4 comments
  • pycharm
  • meditech_project
  • laptop_development
  • python
  • remote_development
  • raspberry-pi
  • sci_fi_your_pi
Related
Recommended

Meditech Annex II - Python development lifecycle on Raspberry PI

balearicdynamics
balearicdynamics
9 Aug 2015

Introduction

As Python is an interpreted language the first temptation for develop applications is directly editing the sources on the Raspberry PI, eventually with the help of the Python idle simple IDE installed by default in raspbian; this development environment is almost primitive, while the availability of a good development environment for the Python language maybe very helpful especially if the code can be managed on the PC while tested real-time on the destination device.

This Meditech project annex explains just how an efficient environment has been set to reach this scope.

 

The role of Python in the software architecture

Pointing the attention to the language Python it has two advantages: it runs fast in the Raspberry PI environment and can be executed (launched) by the command line. The multi-language approach of the entire Meditech project is draft in the following table:

 

Language / EnvironmentUsage
C++Building programs and command line commands to to the hard work: communication, calculation, data processing
SQLDirect access via queries from bash commands for internal data organization and database management
PhpExternal access via Apache2 web server supporting database integration
BashPre-built commands to manage complex tasks and simplify the inter-process communication
PythonLocal User Interface and on-screen real-time monitoring

 

Simplifying the Python development

As explained in the Annex I also in this case the best way to simplify the development lifecycle is adopting an external development IDE. After several tries, I have decided to use the  PyCharm Community Edition IDE (free open source version).

image

I should recognize that this product from JetBrains demonstrated a very efficient instrument for the language development.

In the case of Python we have not the need of the remote compilation as it is based on the Python interpreter. A potentially risk factor working with an external IDE is due by the raspbian libraries not available on other platforms; anyway this aspect can be ignored because the advantages are worthy. Like the case of NetBeans IDE for C++, also PyCharm is simple to download and install. An appreciable aspect is the good available documentation accessible from the PyCharm IDE and the good contextual help support provided, as well as the editor features supporting depth syntax checking and indentation control.

 

The Python development environment

The way followed creating a Python development environment is a bit different than the remote compilation settings requiring to add some changes and integrations.

 

Minimal requirements

The minimal requirements on the Raspberry PI side requires as usual the SSH connectivity; it is essential while developing on a remote linux embedded device to reach the system from a terminal. The minimal requirements settings on the PI are the following:

  • NFS server for folder sharing
  • SSH remote access (supporting the graphical environment on the PC with the -Y option as an alternative to a headless Raspberry PI)
  • A couple of simple Bash commands to fasten the synchronization
  • The possibility to mount on the PC the Raspberry PI remote folder. Also in this case on the Mac OSX a Bash command has been built
  • A simple command to keep synchronize the PC development folder with the Raspberry PI test folder
  • Python installed on the system (it is by default on raspbian)

 

Raspberry PI configuration

The Raspberry PI configuration is really simple. The only change you need is to export the development folder to the NFS server so it is shared remotely by the PC connected on the same LAN.

 

Note: it is best practice to export the folder limited to the development PC IP address.

 

Supposing the following initial conditions,

  • The PC address on the network is 192.168.1.5
  • The Raspberry PI IP address is 192.168.1.99
  • The Raspberry PI folder to share is /home/pi/GitHub

 

execute the following command to edit the exported (shared) folders:

 

sudo nano /etc/exports

 

Then add the following line, accordingly with your real PC and Raspberry IP address and foldert to share

 

/home/pi/GitHub 192.168.1.5/0(rw,async,insecure,no_subtree_check,no_root_squash)

 

After saving the file, reload the NFS server with the following command to restart the NFS sharing service

 

sudo /etc/init.d/nfs-kernel-server restart

 

At this point your folder can be mounted on the remote PC. This example will work with a development PC based on Linux (Ubuntu, Debian etc.) or Mac OSX. For Windows see the how to share a folder from Raspberry PI with the Samba protocol to reach the same result (the same document is attached to this post).

 

PC remote folder mounting

Now that the Raspberry PI folder is shared on the LAN for the specific IP address of our development PC we should mount the remote folder so it is available locally on the PC. To do this avoiding to repeat the mount command it is sufficient to write a short bash comand that we will launch everytime we need to develop with the PI. In the following example the command refers to my local development folder on the Mac, so you should adapt it accordingly with your computer folder structure.

 

#!/bin/bash

# Mount RPI master Meditech Python repository and launch the ide.
sudo mount -o resvport,rw -t nfs 192.168.1.99:/home/pi/GitHub/meditech_python_interface meditech_python_interface/

 

At this point all can be considered done. We should simply start the PyCharm IDE on the PC and open projects and build them directly in this folder. To make the things more reliable a small improvement has been done.

While the remote Python development folder is mounted as meditech_python_interface/ an identical folder named local.meditech_python_interface/ has been created on the PC. So the PyCharm IDE sources are written in the local... folder and wen the python code should be run on the raspberry PI platform it is synchronized with the remote folder overwriting still existing files; in this way there is a local and remote replica of the sources, just like an anticipated backup image

Also in this case the synchronization task is simplified by a bash command wrote once and executed in seconds everytime it is needed.

 

#!/bin/bash

# Update the remote mount files from the local development folder
sudo cp local.meditech_python_interface/* meditech_python_interface/

 

 

The Python development scenario

We can comfortable develop our Python applications on the Raspberry PI with only three windows:

 

  • The PyCharm IDE window
  • A local terminal session
  • A Raspberry PI remote SSH terminal session

 

The following image shows the PC with the Python develompent settings

image

Attachments:
imageHow-To Share a folder with a Windows computer from a Raspberry Pi.pdf
  • Sign in to reply

Top Comments

  • DAB
    DAB over 10 years ago +1
    Nice post. I may have to look into Pycharm. DAB
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to Workshopshed +1
    Hi Andy, to be honest as you know I followed all your development project lifecycle and saw you mentioning the PyCharm then as I read this the facebook site started to show me banners on PyCharm so I installed…
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to Workshopshed

    Hi Andy,

    to be honest as you know I followed all your development project lifecycle and saw you mentioning the PyCharm then as I read this the facebook site started to show me banners on PyCharm so I installed it and found it really well done and the community version is more than sufficient for any kind of development, I think.

     

    Enrico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 10 years ago

    I'm a big fan of Pycharm, I used it for developing and debugging the Python code for the enchanted cottage project. I did find a few issues with libraries that were easy to install on the PC but not on the Arduino Yún

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • balearicdynamics
    balearicdynamics over 10 years ago in reply to DAB

    Thank you DAB, it is time to update the annexes and complete the entire design ... Time is passing image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 10 years ago

    Nice post.

     

    I may have to look into Pycharm.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube