ImportError: cannot import name 'Memgraph' from 'langchain_memgraph'
HI I am encountering an ImportError when attempting to import MemoryGraph from mem0.memory.memgraph_memory. The error states: cannot import name 'Memgraph' from 'langchain_memgraph'.
Expected behavior: The MemoryGraph class should be successfully imported, as langchain-memgraph is installed in the environment.
Observed behavior: An ImportError is raised, preventing the successful import of MemoryGraph. The traceback indicates an issue with importing Memgraph from the langchain_memgraph package.
Steps to reproduce:
Install langchain-memgraph:
Bash
pip install langchain-memgraph Verify installation (output below confirms installation):
Bash
pip show langchain-memgraph Name: langchain-memgraph Version: 0.1.0 Summary: An integration package connecting Memgraph and LangChain Home-page: Author: Author-email: License: MIT Location: /opt/homebrew/anaconda3/envs/my_py311_env/lib/python3.11/site-packages Requires: langchain-core, neo4j Attempt to import MemoryGraph (this command triggers the error):
Bash
python -c "from mem0.memory.memgraph_memory import MemoryGraph; print('Success')" Error traceback:
Traceback (most recent call last):
File "/opt/homebrew/anaconda3/envs/my_py311_env/lib/python3.11/site-packages/mem0/memory/memgraph_memory.py", line 6, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
Python Version: 3.11 (within a conda environment: my_py311_env)
Operating System: macOS (based on /opt/homebrew)
langchain-memgraph Version: 0.1.0
looks like your env doesn't have langchain-memgraph. Can you confirm it if it's folder exists in site-packages?
looks like your env doesn't have langchain-memgraph. Can you confirm it if it's folder exists in site-packages?
Yes, I can confirm that the langchain_memgraph folder does exist within the site-packages directory of the Python environment I'm using.
Here's the relevant line from the pip show langchain-memgraph output, which indicates its location:
Bash
pip show langchain-memgraph Name: langchain-memgraph Version: 0.1.0 Summary: An integration package connecting Memgraph and LangChain Home-page: Author: Author-email: License: MIT Location: /opt/homebrew/anaconda3/envs/my_py311_env/lib/python3.11/site-packages Requires: langchain-core, neo4j Attempt to import MemoryGraph (this command triggers the error):
@mrzch03 Try 0.1.5 version of memgraph. I have used venv and uv for my projects and it works for me. Maybe try to recreate the environment again.
same error
@growmuye you can try restarting the terminal session / ide, deleting and recreating a new environment or clearing the system cache. This issue is likely with the environment setup and not the mem0. Do let me know how it turns out.
@growmuye you can try restarting the terminal session / ide, deleting and recreating a new environment or clearing the system cache. This issue is likely with the environment setup and not the mem0. Do let me know how it turns out.
I switched to Neo4j... now there's no problem.
memgraph is simply a piece of shit. I've have the same problem