0
votes

I'm having trouble with my code in python using neo4j.

My code:

from neo4jrestclient.client import GraphDatabase

db = GraphDatabase("http://localhost:7474",username="neo4j", password="neo4j")

# Create some nodes with labels
user = db.labels.create("User")
u1 = db.nodes.create(name="Marco")
user.add(u1)
u2 = db.nodes.create(name="Daniela")
user.add(u2)

beer = db.labels.create("Beer")
b1 = db.nodes.create(name="Punk IPA")
b2 = db.nodes.create(name="Hoegaarden Rosee")
# You can associate a label with many nodes in one go
beer.add(b1, b2)

# User-likes->Beer relationships
u1.relationships.create("likes", b1)
u1.relationships.create("likes", b2)
u2.relationships.create("likes", b1)
# Bi-directional relationship?
u1.relationships.create("friends", u2)

The error: Traceback (most recent call last): File "/home/jessica/NetBeansProjects/NovoBanco/src/novobanco.py", line 1, in from neo4jrestclient.client import GraphDatabase ImportError: No module named neo4jrestclient.client

1

1 Answers

0
votes

The neo4jrestclient package isn't accessible to the the Python interpreter that you're using. E.g.

$ python
>>> from neo4jrestclient.client import GraphDatabase
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named neo4jrestclient.client

Install the package:

$ sudo pip install neo4jrestclient
[...]
Successfully installed neo4jrestclient-2.1.1

... and then you should be able to move forward with your project:

>>> from neo4jrestclient.client import GraphDatabase

(no error this time).