Legal Innovation & Technology Lab
@ Suffolk Law School
Install Jupyter Notebooks
The following is a quick start guide for setting up Project Jupyter notebooks.
Download, Install, and Run Notebooks
Download and install Anaconda (a free software distribution which includes everything you need to use Jupyter). See https://www.continuum.io/downloads. Lab students, you should download Python 3.6.
- Open a terminal/command prompt and navigate to the directory where you want to be working (e.g.,
- At the prompt enter:
jupyter notebookThat should open up a new tab in your web browser.
- You should see a drop-down menu in the upper right labeled "New." Click on that, and choose "Python 3" (or 3.6 if available) under "Notebooks."
- That should open a new notebook. Basically, you put your code in cells and run them as needed. As this Nature article makes clear, this is a great way to collaborate and keep all your work in one place. You should see something like the image below. The cell preceded by
In [ ]:is where you will type your code.
- To test to make sure everything is working, let's print the output "Hello World!" In Python 3, this is done by typing
print ()with your desired output inside the parentheses. So go ahead and type
print ("Hello World!")into the cell. Text has to go inside quotation marks.
- To run your code, make sure that your cursor is in the cell. Hit the run code button, the one that looks like the 'next track button' on CD player (right arrow with bar). This will run your code, and directly below your cell, you’ll see your output.
- If your notebook looks like the screen shot above, you're ready to go. Here are some example notebooks to get you started. Just cut-and-paste from these examples and start playing.
† These instructions are addapted from Hello, World! Should Attorneys Learn to Code? (instructions at end). Read the full article for more context.
Common Speed Bumps
If you're using Python on your computer for other stuff you may run into all sorts of version issues. In this case, you may want to consider using virtual environments. That being said, if you start to play around and get an error like:
NameError: name 'pd' is not defined
That means that your notebook hasn't loaded a module with the name
pd. So either, you’re missing something like this:
import numpy as np
or the module isn't installed on your system. If it's the latter, you’ll get an error like:
ImportError: No module named 'numpy'
when you try to import the module. To install a module, all you have to do is go to the terminal/command prompt and type:
conda install [module name]For example:
conda install numpy
If Anaconda can't find the module, you may want to try pip like so:
pip install [module name]