HW0.6: Install Python and Our Various Python Packages

This step assumes you've already done HW0.2 and HW0.3.

We use some specialized and finicky Python packages in this class, and they're very difficult to install correctly on your own. Fortunately, there's a Python distribution called Canopy that makes everything Just Work™. Everyone in this class must use Canopy.*

  1. Go to the Canopy licensing page, make sure the “For Academics” tab is selected, and then click on the blue “Request your license” button on the right-hand side. (We need some advanced packages that are not provided in the free “Canopy Express” version, so we need to use our PA credentials to get the full version.)
  2. On the next page, create an account using “Phillips Academy Andover” as your Organization and your PA email address. Don't give them your phone number; that's creepy.
  3. Check your email, activate your account, and then repeat step 1. You should now see a box saying “You have an academic license already!”. Below that is a link to “download Enthought Canopy”. Click it, download the installer, run the installer, and then delete the installer.
  4. Once it's installed, run the Canopy program. It will ask you some configuration questions; the defaults should be fine. Make sure you say that you do want to use Canopy for your command-line Python version.
  5. After confirming all that, you should get the Canopy welcome screen, with a few different buttons. Click on “Editor” and confirm that the Canopy editor, with an interactive prompt in the bottom pane, pops up. Type print "Hello" at the prompt, and it should say hi back to you. If that works, Canopy is installed — keep reading below for your hand-in.

Special instructions for Windows

If you have Cygwin installed (which you should), then you need to do some extra work to get Canopy to work within Cygwin. Here are the steps:

  1. Ensure that Canopy is installed correctly.
  2. Now we need to set up an alias to tell Cygwin to use Canopy's version of Python.

    In Windows Explorer, open up your Cygwin home directory: C:/cygwin64/home/[Your Windows username]/. Find the file called .bashrc and open it with a text editor.

    At the end of your .bashrc file, add this line:

    alias python='C:/Users/[Your Windows username]/AppData/Local/Enthought/Canopy/User/python.exe -i'

    Save the file, exit your editor, and then do the hand-in steps below in Cygwin.

Hand-in: follow these steps and then take a screenshot.

  1. Open a new terminal.
  2. On the command line, enter the command python to start up the Python interactive interpreter. Then enter the commands given after each >>> below. You should see output similar to what the example shows. If it differs greatly (for example, if sys.prefix evaluates to a non-Canopy path), your configuration has an issue that you'll need to resolve before moving on.

    Enthought Canopy Python 2.7.10 | 64-bit | (default, Oct 21 2015, 09:09:19) 
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.6)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys
    >>> sys.prefix
    '/Users/jmiles/Library/Enthought/Canopy_64bit/User'
    >>> import numpy
    >>> numpy.__version__
    '1.9.2'
    >>> numpy.eye(2)
    array([[ 1.,  0.],
           [ 0.,  1.]])
    >>> import matplotlib
    >>> matplotlib.__version__
    '1.4.3'
    >>> from PySide import QtGui
    >>> app = QtGui.QApplication(sys.argv)
    >>> wid = QtGui.QWidget()
    >>> wid.resize(250,150)
    >>> wid.setWindowTitle('Simple')
    >>> wid.show()
    >>> app.exec_()
    

    A little gray window should pop up. Take a screenshot showing this window and the contents of your Python session. Then close the window and press Control+D to exit out of the Python interactive interpreter.

⟵ Back to the main assignment

* The only exception is this: if you run Linux and you're very good at using the package manager, I'm okay with you not installing Canopy. Instead, you'll have to install (and possibly configure) all the Python packages we rely on, as well as their dependencies. I've gone this route before on my own Linux system, and it was a huge pain. I will not provide any tech support if you choose not to use Canopy.