Tuesday, September 11, 2012


So, Batman has Robin, Sherlock Holmes has Dr John Watson, Sheriff Andy Taylor has Deputy Barney Fife... Well, you get the idea: All heroes have a sidekick (if not, they are missing out).

You need a sidekick

Or at least, your desktop does.

If your desktop is a Raspberry Pi, then you already know the life of a sidekick well, or at least you are learning it. This article is not really for you, although it might come in handy later. So, for all you Raspberry Pi owners who do everything on the Raspberry Pi, stay tuned to this blog for a future post: The Sidekick's Sidekick.

Unix, Linux or Mac Desktop

This will be smooth sailing. Open a terminal and type:
 $ ssh -X pi@raspberrypi  
 pi@raspberrypi's password:   
 Linux raspberrypi 3.1.9+ #168 PREEMPT Sat Jul 14 18:56:31 BST 2012 armv6l  
 The programs included with the Debian GNU/Linux system are free software;  
 the exact distribution terms for each program are described in the  
 individual files in /usr/share/doc/*/copyright.  
 Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent  
 permitted by applicable law.  
 Type 'startx' to launch a graphical session  
 Last login: Tue Sep 11 15:32:33 2012 from v480-sunray  
 pi@raspberrypi ~ $   
The first time you will be asked to accept the host key, say yes. Enter your password when prompted. If you entered the correct password, you are in.

Windows (XP, 7, ...)

Ok, this is a little more involved.
  1. Download Putty
  2. Enter the following information in the configuration:
  • Hostname: raspberrypi
  • go to the ssh tab and click X11 forwarding
  • Entere for Saved Session: raspberrypi
  • click Save

I'm not going to go through all the details here. Simply to say that you need to go to the ssh tab and click X11 forwarding download Xming server which will add an X server to Windows. You then need to start the Xming server from the start menu, then open the session in Putty. For more detail, go here
  • Double click on raspberrypi (or select and click open)
You will be asked to accept the host key, say yes. Enter your userid (pi) and password when prompted. If you entered the correct password, you are in.
With that setup however, you only get a fraction of the functionality of what we did for Unix, Linux or Mac.

What are we doing again?

You can now run any console application directly in that window, but even more interesting is the fact that you can run a graphical application on your Raspberry Pi, but the graphical display itself will be on your desktop.

Look, Ma, no VNC! For example, you want to run the midori browser. In the ssh window, at the prompt, type: midori
 $ pi@raspberrypi ~ $ midori
And you should get:
Or perhaps you want to write some Python code. After all, this is a Python centric blog...
 $ pi@raspberrypi ~ $ idle
And you should get:
Now, remember, although the idle window is on my desktop, when I type import web, it is importing a library on the Raspberry Pi, and not from my desktop. By default, web.py is not installed by default.

To install:

pi@raspberrypi ~/Desktop $ sudo easy_install web.py
Searching for web.py
Best match: web.py 0.37
Processing web.py-0.37-py2.7.egg
web.py 0.37 is already the active version in easy-install.pth

Using /usr/local/lib/python2.7/dist-packages/web.py-0.37-py2.7.egg
Processing dependencies for web.py
Finished processing dependencies for web.py

In the above example, it actually didn't download the library, because I had installed it already. In fact, one of the first thing I did. Web.py is like duct tape for web applications. Or Web services. Or template driven apps. Or scripts that need database access. I could go on. Although a web framework, each module can be used individually, or can be replaced, or used alongside similar modules. On the screenshot, I did a dir(web) to show what modules are available. If there is some interest, I'll do a tutorial on using web.py, just let me know in the comments.

Concluding on this way of working, I could be editing python code in idle, while viewing the result of my web application in a web browser (either locally through midori or remotely using my desktop's browser). But that, is just touching the tip of the iceberg. There will be more to come in the coming weeks.

Part 2


  1. also important to add that you can use user@192.168.0.x instead of user@ local host

  2. I'm on a Mac and there is no way I can get this to work. I just get "Cannot open display". doing echo $DISPLAY just returns a blank line. I'm running latest OS X and latest / updated raspberry pi.
    Any idea's?