Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Clone this wiki locally
All the labs and assignments in this course are Python-based. This page provides information about configuring Python on your machine.
Step 0 The IPython notebook runs in the browser, and works best in Google Chrome. You probably want to use Chrome for assignments in this course
Recommended Method: Anaconda
The Anaconda Python distribution is an easily-installable bundle of Python and many of the libraries used throughout this class. Unless you have a good reason not to, we recommend that you use Anaconda.
- Download the appropriate version of Anaconda
- Follow the instructions on that page to run the installer
- Test it out: open a terminal window, and type
python, you should see something like
Python 2.7.5 |Anaconda 1.6.1 (x86_64)| (default, Jun 28 2013, 22:20:13)
Anaconda doesn't appear on the first line, you are using a different version of Python. See the troubleshooting section below.
- Test out the IPython notebook: open a Terminal window, and type
ipython notebook. A new browser window should pop up.
New Notebookto create a new notebook file
- Update IPython to the newest version by typing
conda update ipythonat the command line
- Download the appropriate version of Anaconda
- Follow the instructions on that page to run the installer. This will create a directory at
- Test it out: start the Anaconda launcher, which you can find in
C:\Anacondaor, in the Start menu. Start the IPython notebook. A new browser window should open.
New Notebook, which should open a new page.
- Update IPython to the newest version by opening a command prompt, and typing
conda update ipython
If you did not add Anaconda to your path, be sure to use the full path to the python and ipython executables, such as
Installing additional libraries
Anaconda includes most of the libraries we will use in this course, but you will need to install a few extra ones:
The recommended way to install these packages is to run
pip install BeautifulSoup mrjob pattern seaborn pyquery on the command line. If this doesn't work, you can download the source code, and run
python setup.py install from the source code directory. On Unix machines, either of these commands may require
sudo pip install... or
Opening IPython Notebooks
To view an IPython notebook, you must first start the IPython notebook server in the directory where the file lives. Simply navigate to this directory at the command prompt, and type
ipython notebook. This will open a browser window, listing all the
ipynb files in that directory.
Updating from older Anaconda versions
You can easily update to the latest Anaconda version by updating conda, then Anaconda as follows:
conda update conda conda update anaconda
When you start python, you don't see a line like
Python 2.7.5 |Anaconda 1.6.1 (x86_64)|. You are using a Mac or Linux computer
Reason You are most likely running a different version of Python, and need to modify your Path (the list of directories your computer looks through to find programs).
Find a file like
.profile. Open the file in a text editor, and add a line at this line at the end:
export PATH="$HOME/anaconda/bin:$PATH". Close the file, open a new terminal window, type
source ~/.profile (or whatever file you just edited). Type
which python -- you should see a path that points to the anaconda directory. If so, running
python should load the proper version
If this doesn't work (typing
which python doesn't point to anaconda), you might be using a different shell. Type
echo $SHELL. If this isn't
bash, you need to edit a different startup file (for example, if if
echo $SHELL gives
$csh, you need to edit your
.cshrc file. The syntax for this file is slightly different:
set PATH = ($HOME/anaconda/bin $PATH)
Problem You are running the right version of python (see above item), but are unable to import numpy.
Reason You are probably loading a different copy of numpy that is incompatible with Anaconda
See the above item to find your
.bashrc file. Open it, and add the line
unset PYTHONPATH at the end. Close the file, open a new terminal window, type
source ~/.profile (or whatever file you just edited), and try again.
Problem Under Windows, you receive an error message similar to the following: "'pip' is not recognized as an internal or external command, operable program or batch file."
Reason The correct Anaconda paths might not be present in your PATH variable, or Anaconda might not have installed correctly.
Solution Ensure the Anaconda directories to your path environment variable ("\Anaconda" and "\Anaconda\Scripts"). See this page for details.
If this does not correct the problem, reinstall Anaconda.