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)
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 # lab1.py 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
lab1.py in your
lab1 folder on your Desktop.
Here's the above steps from start to finish:
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
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.
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
lab1.py 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:
- Click on the Run Button (green arrow)
- Goto Run :: Run File
- Use the keyboard shortcut
In this case, you'll know your program succesfully ran because it should say
Hello World! in the Python pane:
Table of Contents
- Lab 1 Home
- Part 1: Lab workflow with Cyberduck
- Part 2: Canopy intro
- Part 3: Text in boxes & Codder
- Part 4: cs1graphics
- Part 5: Save your work