Lab 1: Part 2: Canopy

In this course, we'll edit and run our Python code using Canopy.

(Tip: To download Canopy on your personal computer at home, read more at Computing at Home)

Starting Spring 2019, CS111 uses Python 3 (rather than Python 2.7). It is VERY IMPORTANT that you select the version of Canopy that uses Python 3 (because the Canopy version that uses Python 2.7 will not run your code).

Step 0) On the lab computer, using Spotlight, find and open Canopy.

Once Canopy is open, we want to create a Python file for today's lab and save it in the lab01 folder on your desktop. Here are the steps to do that...

Step 1) From the Welcome screen click the Editor button.

Step 2) From the main window click the Create a new file button.

Step 3) In the new file, start out with this code, replacing the first line with your name:

# Your Name (e.g. Wendy Wellesley)
# username (e.g. wwellesl)
# CS111, Lab 1
# Jan 30, 2019

print('Hello World!')

The first four lines are comments identifying the file and you should follow this pattern for all files you create in this course.

The final line is a simple print statement we'll use in a moment to confirm our program is running.

Step 4) Save the file as in your lab1 folder on your Desktop.

Here's the above steps from start to finish:

Working Directory

When working in Canopy, you always want your Working Directory to match the directory from which you're working (in today's case, that's ~/Desktop/lab01).

To do this, on the right side of the Canopy you'll see a file path followed by a down arrow— click the down arrow to choose your Working Directory, and set it to Keep Directory Synced To Editor.

File Browser

If you don't see the File Browser pane on the left of your Canopy window, go to View and check off File Browser.

Now, in the File Browser pane, right click your file and choose Add directory as Top-level.

Now the lab01 folder and all of its files are quickly accessible from the File Browser.

Run your file

You can run your file via one of the following methods:

  1. Click on the Run Button (green arrow)
  2. Goto Run :: Run File
  3. Use the keyboard shortcut Command + R

In this case, you'll know your program succesfully ran because it should say Hello World! in the Python pane:


Table of Contents