Install Anaconda on your computer

Download Anacaonda version 4.1.1 with Python version 2.7 for your platform (Windows / Mac/ Linux) here. Follow the installation instructions.

Running Python after installation

Python is typically invoked from the command-line like this:

$ python  # is a file containing a Python program

However, you need to make sure that you invoke the correct version of Python. The CS lab computers have multiple versions of Python installed—your computer probably does too.

One way to ensure you use the correct version is to specify the full path:

$ ~/anaconda2/bin/python  # Typical install location for personal Mac
$ /anaconda/bin/python    # Location on lab machine

To avoid typing the full path every time, you can set your system PATH variable so that the directory of the desired python appears first on your path. For example, in the bash shell:

$ export PATH="/Users/sheldon/anaconda2/bin:$PATH"
$ python   # Finds python in /Users/sheldon/anaconda2/bin

On Mac/Linux systems, you can add the export command to your .bash_profile file so it runs automatically when you start a terminal session. Note: the Anaconda installer offers an option to do this at install time, in which case you may not need to do anything.

You can check that you have set the PATH correctly by seeing which python the system finds:

$ which python 

Command-line help

If you are new to the command-line:

Other ways of running Python

iPython / Jupyter notbooks

A Jupyter notebook lets you write and execute Python code interactively in your web browser. It is a powerful way to interact with code and also to mix Python code with beatifully rendered text and math for the purposes of exposition. (Jupyter notebooks were formerly called iPython notebooks.) You can start Jupyter like this:

$ jupyter notebook

This will launch the Jupyter App and open a browser window on the computer. In the browser you can create a new notebook to interactively write and execute Python code. It looks like this:

Read this tutorial for more information on running Jupyter notebooks.

Interactive command-line Python

Python can be launched with no arguments:

$ python 

This launches an interactive session where you can type commands that execute interactively, similar to R or MATLAB:

Python 2.7.12 |Anaconda 4.1.1 (x86_64)| (default, Jul  2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: and
>>> x = 1
>>> print x
>>> y = x
>>> x = x+1
>>> print y

This mode can be very useful.


For interactive sessions, the program ipython (“interactive Python”) may offer advantages. It is invoked the same way:

$ ipython

The iPython interactive session looks a bit different, and provides additional capabilities:

Python 2.7.12 |Anaconda 4.1.1 (x86_64)| (default, Jul  2 2016, 17:43:17)
Type "copyright", "credits" or "license" for more information.

IPython 4.2.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: x = 1

In [2]: print x

In [3]: x = x+1

In [4]: print x

PyCharm: an IDE

PyCharm is a cross-platform IDE for Python which has most popular programming features. Anaconda is a rich set of most useful Python packages (contains Python compiler already). Both of them are free and easy to install. You can choose the OS you are familiar with.

Students can choose from two free versions of PyCharm: PyCharm Community or PyCharm Edu.

One significant advantage of an IDE is debugging support.