Cannot Import creat_react_agent from langgraph.prebuilt #526

Closed
opened 2026-02-20 17:40:34 -05:00 by yindo · 15 comments
Owner

Originally created by @adv-11 on GitHub (Mar 21, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use GitHub Discussions.
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

from langgraph.prebuilt import create_react_agent

langgraph_agent_executor = create_react_agent(model, tools)


messages = langgraph_agent_executor.invoke({"messages": [("human", query)]})
{
    "input": query,
    "output": messages["messages"][-1].content,
}

Error Message and Stack Trace (if applicable)

ImportError: cannot import name 'create_react_agent' from 'langgraph.prebuilt' (unknown location)

Description

from langgraph.prebuilt import create_react_agent
ImportError: cannot import name 'create_react_agent' from 'langgraph.prebuilt' (unknown location)

System Info

from langgraph.prebuilt import create_react_agent
ImportError: cannot import name 'create_react_agent' from 'langgraph.prebuilt' (unknown location)

Originally created by @adv-11 on GitHub (Mar 21, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use GitHub Discussions. - [x] I added a clear and detailed title that summarizes the issue. - [x] I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example). - [x] I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue. ### Example Code ```python from langgraph.prebuilt import create_react_agent langgraph_agent_executor = create_react_agent(model, tools) messages = langgraph_agent_executor.invoke({"messages": [("human", query)]}) { "input": query, "output": messages["messages"][-1].content, } ``` ### Error Message and Stack Trace (if applicable) ```shell ImportError: cannot import name 'create_react_agent' from 'langgraph.prebuilt' (unknown location) ``` ### Description from langgraph.prebuilt import create_react_agent ImportError: cannot import name 'create_react_agent' from 'langgraph.prebuilt' (unknown location) ### System Info from langgraph.prebuilt import create_react_agent ImportError: cannot import name 'create_react_agent' from 'langgraph.prebuilt' (unknown location)
yindo closed this issue 2026-02-20 17:40:34 -05:00
Author
Owner

@gbaian10 commented on GitHub (Mar 21, 2025):

prebuilt has been separated into a standalone package after version 0.3.0, but the main package still has a default dependency on it.
If you are using a virtual environment, try removing the entire langgraph and then reinstall it.

@gbaian10 commented on GitHub (Mar 21, 2025): `prebuilt` has been separated into a standalone package after version 0.3.0, but the main package still has a default dependency on it. If you are using a virtual environment, try removing the entire langgraph and then reinstall it.
Author
Owner

@vbarda commented on GitHub (Mar 21, 2025):

Thanks @gbaian10 , that's correct. Please reinstall in a fresh venv

@vbarda commented on GitHub (Mar 21, 2025): Thanks @gbaian10 , that's correct. Please reinstall in a fresh venv
Author
Owner

@xsuryanshx commented on GitHub (May 2, 2025):

Already tried in a new env, still facing the same issue smh

@xsuryanshx commented on GitHub (May 2, 2025): Already tried in a new env, still facing the same issue smh
Author
Owner

@xsuryanshx commented on GitHub (May 2, 2025):

Already tried in a new env, still facing the same issue smh

Update: tried with version 0.2.67 and it solved the import issue.

@xsuryanshx commented on GitHub (May 2, 2025): > Already tried in a new env, still facing the same issue smh Update: tried with version `0.2.67` and it solved the import issue.
Author
Owner

@hinthornw commented on GitHub (May 2, 2025):

lol

@hinthornw commented on GitHub (May 2, 2025): lol
Author
Owner

@tensorspace commented on GitHub (May 14, 2025):

Hi @vbarda I have upgraded to langgraph 0.4.7 but I still have this issue. Every package is the latest version including laggraph-prebuilt. Thanks

@tensorspace commented on GitHub (May 14, 2025): Hi @vbarda I have upgraded to langgraph 0.4.7 but I still have this issue. Every package is the latest version including laggraph-prebuilt. Thanks
Author
Owner

@ghost commented on GitHub (May 14, 2025):

I am using this dependencies and after unistalling it worked:

dependencies = [
"fastmcp (>=2.3.3,<3.0.0)",
"langchain (>=0.3.25,<0.4.0)",
"langchain-mcp-adapters (>=0.0.11,<0.0.12)",
"anthropic (>=0.51.0,<0.52.0)",
"openai (>=1.78.1,<2.0.0)",
"langchain-openai (>=0.3.16,<0.4.0)",
"langchain-ollama (>=0.3.2,<0.4.0)",
"black (>=25.1.0,<26.0.0)",
"langchain-community (>=0.3.24,<0.4.0)",
"fastapi (>=0.115.12,<0.116.0)",
"uvicorn (>=0.34.2,<0.35.0)",
"langgraph (>=0.4.3,<0.5.0)"
]

@ghost commented on GitHub (May 14, 2025): I am using this dependencies and after unistalling it worked: dependencies = [ "fastmcp (>=2.3.3,<3.0.0)", "langchain (>=0.3.25,<0.4.0)", "langchain-mcp-adapters (>=0.0.11,<0.0.12)", "anthropic (>=0.51.0,<0.52.0)", "openai (>=1.78.1,<2.0.0)", "langchain-openai (>=0.3.16,<0.4.0)", "langchain-ollama (>=0.3.2,<0.4.0)", "black (>=25.1.0,<26.0.0)", "langchain-community (>=0.3.24,<0.4.0)", "fastapi (>=0.115.12,<0.116.0)", "uvicorn (>=0.34.2,<0.35.0)", "langgraph (>=0.4.3,<0.5.0)" ]
Author
Owner

@mfiqihalayubi commented on GitHub (May 18, 2025):

prebuilt has been separated into a standalone package after version 0.3.0, but the main package still has a default dependency on it. If you are using a virtual environment, try removing the entire langgraph and then reinstall it.

Which package @gbaian10 ? im facing simillar problem

@mfiqihalayubi commented on GitHub (May 18, 2025): > `prebuilt` has been separated into a standalone package after version 0.3.0, but the main package still has a default dependency on it. If you are using a virtual environment, try removing the entire langgraph and then reinstall it. Which package @gbaian10 ? im facing simillar problem
Author
Owner

@gbaian10 commented on GitHub (May 18, 2025):

prebuilt has been separated into a standalone package after version 0.3.0, but the main package still has a default dependency on it. If you are using a virtual environment, try removing the entire langgraph and then reinstall it.

Which package @gbaian10 ? im facing simillar problem

langgraph already includes this prebuilt dependency, so usually, there's no need for additional installation.

If you encounter issues with importing, it's recommended to completely uninstall the package and then reinstall it, rather than simply updating it.

For example, first use pip uninstall langgraph and then pip install langgraph, instead of directly using pip install langgraph.

@gbaian10 commented on GitHub (May 18, 2025): > > `prebuilt` has been separated into a standalone package after version 0.3.0, but the main package still has a default dependency on it. If you are using a virtual environment, try removing the entire langgraph and then reinstall it. > > Which package [@gbaian10](https://github.com/gbaian10) ? im facing simillar problem `langgraph` already includes this `prebuilt` dependency, so usually, there's no need for additional installation. If you encounter issues with importing, it's recommended to completely uninstall the package and then reinstall it, rather than simply updating it. For example, first use `pip uninstall langgraph` and then `pip install langgraph`, instead of directly using `pip install langgraph`.
Author
Owner

@saisavya3199 commented on GitHub (May 19, 2025):

I tried uninstalling and installing langgraph again. But still the same issue. What can be done?

@saisavya3199 commented on GitHub (May 19, 2025): I tried uninstalling and installing langgraph again. But still the same issue. What can be done?
Author
Owner

@ghost commented on GitHub (May 19, 2025):

Try different versions

@ghost commented on GitHub (May 19, 2025): Try different versions
Author
Owner

@kenil-stack commented on GitHub (May 21, 2025):

I have tried uninstalling langgraph completely and then reinstall it completely. But that doesn't works for me.

@kenil-stack commented on GitHub (May 21, 2025): I have tried uninstalling langgraph completely and then reinstall it completely. But that doesn't works for me.
Author
Owner

@francis-bm commented on GitHub (May 22, 2025):

I got it to work:

First:
pip uninstall langgraph
Second:
pip uninstall langgraph_prebuilt

Then:

pip install langgraph

It should work now. The problem was that when you uninstall langgraph, it does not uninstall langgraph_prebuilt, so you need to uninstall as well.
@kenil-stack @saisavya3199

@francis-bm commented on GitHub (May 22, 2025): I got it to work: First: pip uninstall langgraph Second: pip uninstall langgraph_prebuilt Then: pip install langgraph It should work now. The problem was that when you uninstall langgraph, it does not uninstall langgraph_prebuilt, so you need to uninstall as well. @kenil-stack @saisavya3199
Author
Owner

@saisavya3199 commented on GitHub (May 22, 2025):

Yes, this worked. Thanks!

@saisavya3199 commented on GitHub (May 22, 2025): Yes, this worked. Thanks!
Author
Owner

@smsajjadzaidi commented on GitHub (Jun 9, 2025):

worked, thanks @francis-bm

@smsajjadzaidi commented on GitHub (Jun 9, 2025): worked, thanks @francis-bm
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#526