cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Integrating Jupyter Notebook with Neo4J Desktop Database

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?

17 REPLIES 17

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

Via: https://blog.ouseful.info/2019/08/13/neo4j-graph-database-running-in-mybinder/

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

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)

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

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

I used this and still getting the error

And your notebook server is running locally?

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

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

What is the current error message.

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)

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?

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)

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

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/
Connect URL: bolt://localhost:7687

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

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

mmorley
Node Clone

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: https://github.com/menome/neo4j-spatial-experiments/tree/master/1_walkscore

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

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

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")

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online