Skip to content

Latest commit

 

History

History
98 lines (62 loc) · 4.31 KB

XQuartzInstall.md

File metadata and controls

98 lines (62 loc) · 4.31 KB

Introduction:

There are several ways to approach development of Python code on a Raspberry Pi (RPi). These approaches range from simple and free to complex and expensive. Assuming that you are running your RPi in "headless" mode, you can simply launch pico from the command line and begin coding, or you can invest in a commercial development environment such as PyCharm, or Wing. This "recipe" discusses only one approach; an intermediate approach that utilizes the "native" IDLE running on the RPi, and displayed in an X Window on a Mac.

Installation and Setup:

Installation and setup is easy:

1. Download & install XQuartz.

The current version as of this writing is 2.7.11. It runs on Mac OS High Sierra (10.13.x), and on Mojave (10.14.5).

2. Start XQuartz

From the Launchpad, or open -a XQuartz from bash. This will verify that XQuartz has been installed properly. You should see an Xterm window on your desktop as shown below:

Dismiss this window before proceeding (enter `exit` at the command prompt in the Xterm window)

3. Open SSH connection to RPi:

From the Mac's terminal app, initiate a Secure Shell connection to the RPi with the X11 forwarding option: -Y as follows:

ssh -Y [email protected] 
  -- OR -- 
ssh -Y [email protected]

NOTE: the -Y option enables X11 forwarding over SSH, and is ESSENTIAL

4. Verify that idle3 is installed (or install it) on RPi

pi@raspberrypi3b:~ $ apt-mark showmanual | grep idle 
idle3

  -- If idle3 isn't listed, install it as follows: 

pi@raspberrypi3b:~ $ sudo apt-get update
   ... (status of update)
pi@raspberrypi3b:~ $ sudo apt-get upgrade
   ... (status of upgrade)
pi@raspberrypi3b:~ $ sudo apt-get install idle3

5. Start idle3 on RPi:

Note that this may not be "silky smooth"; that is, it may not work the first time you start idle3. If it doesn't, simply exit or Control-C if things are hung in the shell. Then, verify that the file ~/.Xauthority is now present in your RPi home directory:

pi@raspberrypi3b:~ $ ls -la | grep Xauthority
-rw-------  1 pi   pi        177 Jun 19 11:11 .Xauthority

You may wish to run idle3 in the background to keep your terminal window available for other chores:

pi@raspberrypi3b:~ $ idle3 &   

Once the XWindows preliminaries are satisfied, you should be rewarded with the IDLE Editor window as follows:

And if you select Run, Python Shell from the editor menu, another window containing the Python shell will open. Note the syntax coloring and help text displayed during command entry:

6. C'est finis

So - that's all for now. You should have a working Python IDE that you can use remotely for a Raspberry Pi target environment. And since the code and the IDE execute on the RPi, you'll need not worry about surprises when you relocate your code from a foreign development environment.