Authenticating into neo4j in a Jupyter Notebook using py2neo

I recently spend a frustrating few hours trying to replicate these examples in a Jupyter Notebook.

Every time I attempted to run this line...

graph = Graph()

... the trace would go loopy and I'd get a connection refused error. Here's how to get around this problem. 

Start Neo4j

You need a running instance of Neo4j before you even attempt to start running the code. So, either launch the desktop app or, if you prefer, launch an instance from the shell, like so,

$ neo4j start

By default, neo4j will listen on port 7474.

The authentication code

The following code can then be run inside the Notebook (or wherever) and you won't get the error I kept seeing:

from py2neo import authenticate, Graph

# set up authentication parameters
authenticate("localhost:7474", "neo4j", "Nov2015!!")

# connect to authenticated graph database
graph = Graph("http://localhost:7474/db/data/")