I am going through Neo4j & LLM Fundamentals course ( https://graphacademy.neo4j.com/courses/llm-fundamentals/3-intro-to-langchain/5-connecting-to-neo4j/) and getting AttributeError: module 'neo4j' has no attribute 'GraphDatabase'
suggests that the version of the neo4j
library I have installed is not compatible with the version of the langchain_community
library I am using.
Traceback (most recent call last):
File "/Users/thomaspark/PycharmProjects/pythonProject-First/neo4jGraph.py", line 4, in
graph = Neo4jGraph(
File "/Users/thomaspark/PycharmProjects/pythonProject-First/.venv/lib/python3.9/site-packages/langchain_community/graphs/neo4j_graph.py", line 339, in init
self._driver = neo4j.GraphDatabase.driver(
AttributeError: module 'neo4j' has no attribute 'GraphDatabase'
I tried to update both libraries to the latest versions:
pip install --upgrade langchain_community neo4j
langchain_community version is 0.2.1
neo4j is 4.4.3
Hi,
I am actually in the middle of making some updates to this course post the release of langchain 0.2 where a number of components have been deprecated (Im sure you have seen the warnings).
I cant replicate this issue though:
The latest version of neo4j python package is 5.20.0 - neo4j · PyPI - you say you are using 4.4.4?
Here is my output from pip list
.
pyv.txt (3.4 KB)
I get the same error with both neo4j 4.4.3 as well as 5.20.0.
output from pip list with 5.20.0
Package Version
aiohttp 3.9.5
aiosignal 1.3.1
annotated-types 0.7.0
anyio 4.3.0
attrs 23.2.0
certifi 2024.2.2
charset-normalizer 3.3.2
colorama 0.4.6
dataclasses-json 0.6.6
distro 1.9.0
frozenlist 1.4.1
greenlet 3.0.3
h11 0.14.0
httpcore 1.0.5
httpx 0.27.0
idna 3.7
jsonpatch 1.33
jsonpointer 2.4
langchain 0.2.1
langchain-community 0.2.1
langchain-core 0.2.0
langchain-openai 0.1.7
langchain-text-splitters 0.2.0
langchainhub 0.1.15
langsmith 0.1.60
marshmallow 3.21.2
multidict 6.0.5
mypy-extensions 1.0.0
neo4j 5.20.0
numpy 1.26.4
openai 1.30.1
orjson 3.10.3
packaging 23.2
pip 24.0
pydantic 2.7.1
pydantic_core 2.18.2
pytz 2024.1
PyYAML 6.0.1
regex 2024.5.15
requests 2.32.1
sniffio 1.3.1
SQLAlchemy 2.0.30
tenacity 8.3.0
tiktoken 0.7.0
tqdm 4.66.4
types-requests 2.32.0.20240523
typing_extensions 4.11.0
typing-inspect 0.9.0
urllib3 2.2.1
yarl 1.9.4
youtube-search 2.1.2
output from pip list with neo4j.
I think this is because you have a filed named "neo4j.py" in your project.
Python will try to import from "local" files before importing from packages.
i.e. when from neo4j import GraphDatabase
is run, Python is trying to import the GraphDatabase
class from the neo4j.py file in your project.
Got it! After I renamed the file, it works now. Thanks,