Skip to content

Running your first Python program

Shashank Khandelwal edited this page Jun 15, 2014 · 13 revisions

Verifying your Canopy Installation

We are going to verify that your Canopy installation worked, and are going to run your first Python program.

  1. Once Canopy is installed, launch the Canopy GUI. You'll see this screen: Canopy welcome screen

  2. Click on "Editor" Canopy Editor

  3. Click on "Create a new file", and copy and paste in the following code:

# This uses BioPython, and is a good check to ensure that you have installed
# Enthought's Canopy correctly.

from Bio.Seq import Seq

if __name__ == '__main__':
    sequence = Seq('AGTACACTGGT')

    print "Here is a sequence: "
    print sequence

    print "And here is it's complement: "
    print sequence.complement()

The file containing this program is also available here: https://github.com/khandelwal/hoya-python/blob/master/checkpython.py Program pasted in

  1. Click in the green arrow or 'play button' to run this program. The results are show in the bottom pane. You should see output very similar to the following:
%run "/tmp/tmpzJ6Guk.py"
Here is a sequence: 
AGTACACTGGT
And here is it's complement: 
TCATGTGACCA

Congratulations, you've run your (first) Python program!