Jacob Quisenberry
Jacob Quisenberry

Reputation: 1199

py2neo AddressError When Connecting to neo4j in Docker

I am having difficulty creating a Graph object on Neo4j 3.4.6 using py2neo 4.10 with Python 3.7.0.

I created a Docker container running Neo4j, and I disabled authentication using Dockerfile entry ENV NEO4J_AUTH=none. I verified that I can browse to the Neo4j database from the host with http://localhost:7474 and that I was not required to enter a password.

I created a second Docker contain for my web server. I accessed the Bash shell using Docker exec -it 033f92b042c1 /bin/bash. I verified that I can ping the Docker image containing the Neo4j installation.

From the second Docker image, I tried to create a Database object or a Graph object.

import neo4j
import py2neo
from py2neo import Graph
graph = Graph("bolt://172.17.0.3:7687")

I tried different protocols and localhost rather than the IP. In each case, Python throws this:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/py2neo/database.py", line 88, in __new__
    inst = cls._instances[key]
KeyError: '5280a6d494b601f0256493eab3a08e55'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/py2neo/database.py", line 305, in __new__
    database = Database(uri, **settings)
  File "/usr/local/lib/python3.7/site-packages/py2neo/database.py", line 92, in __new__
    from py2neo.internal.http import HTTPDriver, HTTPSDriver
  File "/usr/local/lib/python3.7/site-packages/py2neo/internal/http.py", line 26, in <module>
    from neo4j.addressing import SocketAddress
  File "/usr/local/lib/python3.7/site-packages/neo4j/addressing.py", line 26, in <module>
    from neo4j.exceptions import AddressError
ImportError: cannot import name 'AddressError' from 'neo4j.exceptions' (/usr/local/lib/python3.7/site-packages/neo4j/exceptions.py)

Am I missing a dependency, or is there another way I should be connecting the Docker images?

Upvotes: 0

Views: 1547

Answers (1)

Can Burak Sofyalioglu
Can Burak Sofyalioglu

Reputation: 36

Py2neo doesn't require neo4j. It is possible that the reason is neo4j is creating problem. In my case,be sure to make clean installation, I removed all neo4j-related modules and then install py2neo with its requirement neo4j-driver.

pip uninstall neo4j neobolt neo4restclient neo4j-driver py2neo

then install:
pip install neo4j-driver py2neo

I hope that will work.

Upvotes: 2

Related Questions