mem0 icon indicating copy to clipboard operation
mem0 copied to clipboard

ImportError: cannot import name 'Memgraph' from 'langchain_memgraph'

Open mrzch03 opened this issue 6 months ago • 7 comments

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 from langchain_memgraph import Memgraph ImportError: cannot import name 'Memgraph' from 'langchain_memgraph' (/opt/homebrew/anaconda3/envs/my_py311_env/lib/python3.11/site-packages/langchain_memgraph/init.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/opt/homebrew/anaconda3/envs/my_py311_env/lib/python3.11/site-packages/mem0/memory/memgraph_memory.py", line 8, in raise ImportError("langchain_memgraph is not installed. Please install it using pip install langchain-memgraph") ImportError: langchain_memgraph is not installed. Please install it using pip install langchain-memgraph Environment details:

Python Version: 3.11 (within a conda environment: my_py311_env)

Operating System: macOS (based on /opt/homebrew)

langchain-memgraph Version: 0.1.0

mrzch03 avatar Jul 01 '25 12:07 mrzch03

looks like your env doesn't have langchain-memgraph. Can you confirm it if it's folder exists in site-packages?

Jainish-S avatar Jul 01 '25 15:07 Jainish-S

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 avatar Jul 02 '25 02:07 mrzch03

@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.

Jainish-S avatar Jul 02 '25 03:07 Jainish-S

Image Image

same error

growmuye avatar Jul 14 '25 07:07 growmuye

@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.

parshvadaftari avatar Jul 14 '25 18:07 parshvadaftari

@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.

growmuye avatar Jul 15 '25 04:07 growmuye

memgraph is simply a piece of shit. I've have the same problem

dkoxhorse avatar Oct 29 '25 14:10 dkoxhorse