# Integrating Jupyter Notebook with Neo4J Desktop Database

**URL:** <https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778>\
**Category:** Graph Academy\
**Created:** [August 30, 2019, 1:22am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778 "2019-08-30T01:22:10Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiwari.milind](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tiwari.milind/32/2451_2.png) [@tiwari.milind](https://community.neo4j.com/u/tiwari.milind)\
**Post date:** [August 30, 2019, 1:22am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/1 "2019-08-30T01:22:10Z")

</div>

Hi,

The data science class teaches how to integrate and setup the development environment for a Sandbox. How can I replicate the same for a Neo4J Desktop based graph database for the community edition?

---

<div class="post-metadata">

**Author:** ![psychemedia](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/psychemedia/32/6213_2.png) [@psychemedia](https://community.neo4j.com/u/psychemedia)\
**Post date:** [August 30, 2019, 9:13am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/2 "2019-08-30T09:13:44Z")

</div>

Not sure I understand the question, but here's an example of connecting to a neo4j database from a notebook in Binderhub: [Binder](https://mybinder.org/v2/gh/psychemedia/binder-neo4j/master?filepath=py%2Fneo4j-demo.py)

Via: [Neo4J Graph Database Running in MyBinder – OUseful.Info, the blog…](https://blog.ouseful.info/2019/08/13/neo4j-graph-database-running-in-mybinder/)

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [August 30, 2019, 10:01am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/3 "2019-08-30T10:01:10Z")

</div>

In general, just connect with the python driver to that database, with bolt://host:port + username + password.

---

<div class="post-metadata">

**Author:** ![tiwari.milind](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tiwari.milind/32/2451_2.png) [@tiwari.milind](https://community.neo4j.com/u/tiwari.milind)\
**Post date:** [August 30, 2019, 11:49pm UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/4 "2019-08-30T23:49:00Z")

</div>

I am using the following:  
graph = Graph("bolt://host:7473", auth=("neo4j", ""))

Also tried the other variation:  
graph = Graph("bolt://localhost:7473", auth=("neo4j", "\<Password"))

Moreover, did try the bolt port, https port and http port. Could you advise which one to use.

I am getting the following error:  
KeyError Traceback (most recent call last)  
/usr/local/lib/python3.6/dist-packages/py2neo/database.py in **new** (cls, uri, \*\*settings)  
87 try:  
---\> 88 inst = cls.\_instances[key]  
89 except KeyError:

KeyError: 'ff568088721569ea47d3734156837aa1'

During handling of the above exception, another exception occurred:

ServiceUnavailable Traceback (most recent call last)  
10 frames  
/usr/local/lib/python3.6/dist-packages/neo4j/bolt/connection.py in \_connect(resolved\_address, \*\*config)  
582 \_force\_close(s)  
583 if error.errno in (61, 99, 111, 10061):  
--\> 584 raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved\_address, error.errno))  
585 else:  
586 raise

ServiceUnavailable: Failed to establish connection to ('::1', 7474, 0, 0) (reason 99)

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [August 31, 2019, 12:29am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/5 "2019-08-31T00:29:17Z")

</div>

Bolt port is. 7687 not one of those you used.

---

<div class="post-metadata">

**Author:** ![tiwari.milind](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tiwari.milind/32/2451_2.png) [@tiwari.milind](https://community.neo4j.com/u/tiwari.milind)\
**Post date:** [August 31, 2019, 2:01am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/6 "2019-08-31T02:01:08Z")

</div>

graph = Graph("bolt://localhost:7687", auth=("neo4j", "Jaipur@92"))

I used this and still getting the error

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [August 31, 2019, 11:20am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/7 "2019-08-31T11:20:25Z")

</div>

And your notebook server is running locally?

and you imported the python-driver or py2neo dependency?  
and installed into your notebook?

---

<div class="post-metadata">

**Author:** ![tiwari.milind](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tiwari.milind/32/2451_2.png) [@tiwari.milind](https://community.neo4j.com/u/tiwari.milind)\
**Post date:** [August 31, 2019, 7:41pm UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/8 "2019-08-31T19:41:02Z")

</div>

I am using the online Jupyter notebook through Google colab.

Yes the other drivers are installed using the following commands:

!pip install py2neo==4.1.3 pandas matplotlib sklearn

from py2neo import Graph

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [September 2, 2019, 3:52pm UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/9 "2019-09-02T15:52:06Z")

</div>

What is the current error message.

---

<div class="post-metadata">

**Author:** ![tiwari.milind](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tiwari.milind/32/2451_2.png) [@tiwari.milind](https://community.neo4j.com/u/tiwari.milind)\
**Post date:** [September 2, 2019, 10:10pm UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/10 "2019-09-02T22:10:12Z")

</div>

KeyError Traceback (most recent call last)  
/usr/local/lib/python3.6/dist-packages/py2neo/database.py in **new** (cls, uri, \*\*settings)  
87 try:  
---\> 88 inst = cls.\_instances[key]  
89 except KeyError:

KeyError: 'ff568088721569ea47d3734156837aa1'

During handling of the above exception, another exception occurred:

ServiceUnavailable Traceback (most recent call last)  
10 frames  
/usr/local/lib/python3.6/dist-packages/neo4j/bolt/connection.py in \_connect(resolved\_address, \*\*config)  
582 \_force\_close(s)  
583 if error.errno in (61, 99, 111, 10061):  
--\> 584 raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved\_address, error.errno))  
585 else:  
586 raise

ServiceUnavailable: Failed to establish connection to ('::1', 7474, 0, 0) (reason 99)

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [September 2, 2019, 11:25pm UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/11 "2019-09-02T23:25:09Z")

</div>

But that's again the wrong port in your connection URL.

`ServiceUnavailable: Failed to establish connection to ('::1', 7474, 0, 0) (reason 99)`

can you make sure you fix all connection URL places first?

---

<div class="post-metadata">

**Author:** ![tiwari.milind](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tiwari.milind/32/2451_2.png) [@tiwari.milind](https://community.neo4j.com/u/tiwari.milind)\
**Post date:** [September 3, 2019, 5:30am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/12 "2019-09-03T05:30:17Z")

</div>

> [@tiwari.milind](#):
>
> graph = Graph("bolt://localhost:7687", auth=("neo4j", "Jaipur@92"))

KeyError Traceback (most recent call last)  
/usr/local/lib/python3.6/dist-packages/py2neo/database.py in **new** (cls, uri, \*\*settings)  
87 try:  
---\> 88 inst = cls.\_instances[key]  
89 except KeyError:

KeyError: '7e4b1ff0930024bc0b8c7e1d27464215'

During handling of the above exception, another exception occurred:

ServiceUnavailable Traceback (most recent call last)  
10 frames  
/usr/local/lib/python3.6/dist-packages/neo4j/bolt/connection.py in \_connect(resolved\_address, \*\*config)  
582 \_force\_close(s)  
583 if error.errno in (61, 99, 111, 10061):  
--\> 584 raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved\_address, error.errno))  
585 else:  
586 raise

ServiceUnavailable: Failed to establish connection to ('::1', 7687, 0, 0) (reason 99)

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [September 3, 2019, 1:05pm UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/13 "2019-09-03T13:05:43Z")

</div>

Looks like an ipv6 issue?

Can yo check in your /etc/hosts what the entry is for localhost and possible add 127.0.0.1

---

<div class="post-metadata">

**Author:** ![tiwari.milind](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/tiwari.milind/32/2451_2.png) [@tiwari.milind](https://community.neo4j.com/u/tiwari.milind)\
**Post date:** [September 3, 2019, 10:27pm UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/14 "2019-09-03T22:27:15Z")

</div>

I got the following error when I used graph = Graph("bolt://127.0.01:7687", auth=("neo4j", "Jaipur@92"))

KeyError Traceback (most recent call last)  
/usr/local/lib/python3.6/dist-packages/py2neo/database.py in **new** (cls, uri, \*\*settings)  
87 try:  
---\> 88 inst = cls.\_instances[key]  
89 except KeyError:

KeyError: '5ec4cbd7df2b4ae5c9bc45421a11ca50'

During handling of the above exception, another exception occurred:

ServiceUnavailable Traceback (most recent call last)  
10 frames  
/usr/local/lib/python3.6/dist-packages/neo4j/bolt/connection.py in \_connect(resolved\_address, \*\*config)  
582 \_force\_close(s)  
583 if error.errno in (61, 99, 111, 10061):  
--\> 584 raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved\_address, error.errno))  
585 else:  
586 raise

ServiceUnavailable: Failed to establish connection to ('127.0.0.1', 7687) (reason 111)

When I click on local host in Neo4J desktop I get the following:

Browser URL: [http://localhost:7474/browser/](http://localhost:7474/browser/)  
Connect URL: bolt://localhost:7687

I am not getting anything when I am using the following command:

graph = Graph("[http://localhost:7474/browser/](http://localhost:7474/browser/)", auth=("neo4j", "Jaipur@92"))

---

<div class="post-metadata">

**Author:** ![mmorley](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mmorley/32/2199_2.png) [@mmorley](https://community.neo4j.com/u/mmorley)\
**Post date:** [September 5, 2019, 7:21pm UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/15 "2019-09-05T19:21:20Z")

</div>

Have an example jupyter notebook hooked up to neo4j as part of the walkscore neo4j demo that might help - although it may be using an older python library as it was done last year: [neo4j-spatial-experiments/1\_walkscore at master · menome/neo4j-spatial-experiments · GitHub](https://github.com/menome/neo4j-spatial-experiments/tree/master/1_walkscore)

---

<div class="post-metadata">

**Author:** ![swati.verma](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/swati.verma/32/4387_2.png) [@swati.verma](https://community.neo4j.com/u/swati.verma)\
**Post date:** [April 8, 2020, 4:55am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/16 "2020-04-08T04:55:45Z")

</div>

I am trying the following code to connect Neo4j desktop using python

from neo4j import GraphDatabase  
url = "bolt://localhost:7687"  
driver = GraphDatabase.driver(url, auth=("neo4j", ""))

But getting this error "Failed to establish connection to ('::1', 7687, 0, 0) (reason [Errno 61] Connection refused)"  
Can anyone please suggest what should i change in my code

---

<div class="post-metadata">

**Author:** ![elaine\_rosenber](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/elaine_rosenber/32/27409_2.png) [@elaine\_rosenber](https://community.neo4j.com/u/elaine_rosenber)\
**Post date:** [April 8, 2020, 11:39am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/17 "2020-04-08T11:39:09Z")

</div>

Hello Swati,

So you have a Neo4j instance running locally on your system yes?

If so, it should have been created with a password and the driver() call here has blank for the password which is not correct.

Do you remember what password you used when you created the graph?

You must supply that password here.

Elaine

---

<div class="post-metadata">

**Author:** ![rajdesai024](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/rajdesai024/32/18548_2.png) [@rajdesai024](https://community.neo4j.com/u/rajdesai024)\
**Post date:** [June 3, 2021, 9:47am UTC](https://community.neo4j.com/t/integrating-jupyter-notebook-with-neo4j-desktop-database/9778/18 "2021-06-03T09:47:07Z")

</div>

Hey I am not sure but according to my research as google colab is a cloud-based service it does not support importing data from a local db but if you want to setup a system in a local jupyter notebook here is the code I used, I used py2neo driver for my connection.

from py2neo import Graph  
graph = Graph("bolt://localhost:7687", auth=("neo4j", "yelp"))  
result=graph.run("MATCH (n:User) RETURN n LIMIT 25")
