[Back to CS585 home page]

Getting Started with Python

Installing Python

A few notes on installing Python. Python runs on all OSes (Windows, Mac, Linux) but how you run it on each differs a little bit.

The easiest way to install it is to get the Anaconda Python distribution, which comes with all the libraries you will need. They ask for an email address but you can give them a fake one. Get version 2.7, which is the version we will use in this class.

For assignments we will assume you are using a text editor to edit your files (e.g. Sublime Text or Notepad++ or GEdit or TextMate or vim or emacs, etc.), and running them from the command line (command prompt on Windows, or a terminal shell on Mac/Linux). We will assume you are comfortable working in this manner; please look for help online if you need to learn.

Make sure you know how to execute Anaconda’s version of python from the commandline. This StackOverflow page has some details. (On Mac and Linux, your system will have another version of Python already installed; use which python to figure out how your PATH is being interpreted.)

We (the instructors) are familiar with Mac and Linux, but not with Windows, so we will not be able to help you if you’re using it. Please post in the Piazza forum if you need help.

To make sure everything is working, make sure you can do the following:

For the last step, you’ll probably want to cd into the same directory as where the script is located, then type something like python myscript.py if you have your PATH set up right for the anaconda python; or if you don’t, ~/anaconda/bin/python myscript.py or something like that might work.

Optionally, you can also try running IPython Notebook, which is a fancier form of the interactive interpreter, which is nice for learning how things work.

Python Resources

There are many tutorials and guides to Python online. Learn Python The Hard Way has nice examples for the core of the language. But there are tons of other tutorials out there. If there are ones you like, please post them on Piazza!

When trying to use a library, it’s usually easy to google for “python NAME OF LIBRARY” and look for the standard documentation. For example, we will make heavy use of defaultdict, so to find its documentation, search for “python defaultdict” and one of the first pages that comes up is this page, the Python 2.7 documentation about the collections module, which describes it.