ImportError: cannot import name 'CompiledStateGraph' from 'langgraph.graph' #1051

Closed
opened 2026-02-20 17:42:54 -05:00 by yindo · 1 comment
Owner

Originally created by @khteh on GitHub (Nov 12, 2025).

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • 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.graph import CompiledStateGraph`

Error Message and Stack Trace (if applicable)

Traceback (most recent call last):
  File "/usr/src/Python/rag-agent/.venv/bin/hypercorn", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/hypercorn/__main__.py", line 312, in main
    return run(config)
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/hypercorn/run.py", line 51, in run
    load_application(config.application_path, config.wsgi_max_body_size)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/hypercorn/utils.py", line 99, in load_application
    module = import_module(import_name)
  File "/usr/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/src/Python/rag-agent/src/main.py", line 108, in <module>
    app = asyncio.run(create_app())
  File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run
    return runner.run(main)
           ~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
    return future.result()
           ~~~~~~~~~~~~~^^
  File "/usr/src/Python/rag-agent/src/main.py", line 83, in create_app
    from src.controllers.HomeController import home_api as home_blueprint
  File "/usr/src/Python/rag-agent/src/controllers/HomeController.py", line 26, in <module>
    from langgraph.graph import CompiledStateGraph
ImportError: cannot import name 'CompiledStateGraph' from 'langgraph.graph' (/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/graph/__init__.py)
<sys>:0: ResourceWarning: unclosed <socket.socket fd=3, family=2, type=1, proto=0, laddr=('127.0.0.1', 8000)>
<sys>:0: ResourceWarning: unclosed <socket.socket fd=4, family=2, type=1, proto=0, laddr=('0.0.0.0', 8080)>
<sys>:0: ResourceWarning: unclosed <socket.socket fd=6, family=10, type=2, proto=0, laddr=('::', 4433, 0, 0)>
<sys>:0: ResourceWarning: unclosed <socket.socket fd=5, family=2, type=2, proto=0, laddr=('0.0.0.0', 4433)>

Description

from langgraph.graph import CompiledStateGraph

System Info

System Information
------------------
> OS:  Linux
> OS Version:  #6-Ubuntu SMP PREEMPT_DYNAMIC Tue Oct  7 13:34:17 UTC 2025
> Python Version:  3.13.7 (main, Aug 20 2025, 22:17:40) [GCC 15.2.0]

Package Information
-------------------
> langchain_core: 1.0.4
> langchain: 1.0.5
> langchain_community: 0.4.1
> langsmith: 0.4.42
> langchain_classic: 1.0.0
> langchain_google_genai: 3.0.2
> langchain_neo4j: 0.6.0
> langchain_ollama: 1.0.0
> langchain_postgres: 0.0.16
> langchain_text_splitters: 1.0.0
> langgraph_api: 0.4.28
> langgraph_cli: 0.4.7
> langgraph_runtime_inmem: 0.14.1
> langgraph_sdk: 0.2.9

Optional packages not installed
-------------------------------
> langserve

Other Dependencies
------------------
> aiohttp: 3.13.2
> asyncpg: 0.30.0
> blockbuster: 1.5.25
> click: 8.3.0
> cloudpickle: 3.1.2
> cryptography: 44.0.3
> dataclasses-json: 0.6.7
> filetype: 1.2.0
> google-ai-generativelanguage: 0.9.0
> httpx: 0.28.1
> httpx-sse: 0.4.3
> jsonpatch: 1.33
> jsonschema-rs: 0.29.1
> langgraph: 1.0.3
> langgraph-checkpoint: 3.0.1
> neo4j: 5.28.2
> neo4j-graphrag: 1.10.1
> numpy: 2.3.4
> ollama: 0.6.0
> opentelemetry-api: 1.38.0
> opentelemetry-sdk: 1.38.0
> orjson: 3.11.4
> packaging: 25.0
> pgvector: 0.3.6
> psycopg: 3.2.12
> psycopg-pool: 3.2.7
> pydantic: 2.12.4
> pydantic-settings: 2.12.0
> pyjwt: 2.10.1
> pytest: 9.0.0
> python-dotenv: 1.2.1
> pyyaml: 6.0.3
> PyYAML: 6.0.3
> requests: 2.32.5
> requests-toolbelt: 1.0.0
> sqlalchemy: 2.0.44
> SQLAlchemy: 2.0.44
> sse-starlette: 2.1.3
> starlette: 0.49.3
> structlog: 25.5.0
> tenacity: 9.1.2
> truststore: 0.10.4
> typing-extensions: 4.15.0
> uvicorn: 0.38.0
> watchfiles: 1.1.1
> zstandard: 0.25.0
Originally created by @khteh on GitHub (Nov 12, 2025). ### Checked other resources - [x] This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/). - [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.graph import CompiledStateGraph` ``` ### Error Message and Stack Trace (if applicable) ```shell Traceback (most recent call last): File "/usr/src/Python/rag-agent/.venv/bin/hypercorn", line 10, in <module> sys.exit(main()) ~~~~^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/hypercorn/__main__.py", line 312, in main return run(config) File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/hypercorn/run.py", line 51, in run load_application(config.application_path, config.wsgi_max_body_size) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/hypercorn/utils.py", line 99, in load_application module = import_module(import_name) File "/usr/lib/python3.13/importlib/__init__.py", line 88, in import_module return _bootstrap._gcd_import(name[level:], package, level) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1387, in _gcd_import File "<frozen importlib._bootstrap>", line 1360, in _find_and_load File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 935, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 1026, in exec_module File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "/usr/src/Python/rag-agent/src/main.py", line 108, in <module> app = asyncio.run(create_app()) File "/usr/lib/python3.13/asyncio/runners.py", line 195, in run return runner.run(main) ~~~~~~~~~~^^^^^^ File "/usr/lib/python3.13/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^ File "/usr/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete return future.result() ~~~~~~~~~~~~~^^ File "/usr/src/Python/rag-agent/src/main.py", line 83, in create_app from src.controllers.HomeController import home_api as home_blueprint File "/usr/src/Python/rag-agent/src/controllers/HomeController.py", line 26, in <module> from langgraph.graph import CompiledStateGraph ImportError: cannot import name 'CompiledStateGraph' from 'langgraph.graph' (/usr/src/Python/rag-agent/.venv/lib/python3.13/site-packages/langgraph/graph/__init__.py) <sys>:0: ResourceWarning: unclosed <socket.socket fd=3, family=2, type=1, proto=0, laddr=('127.0.0.1', 8000)> <sys>:0: ResourceWarning: unclosed <socket.socket fd=4, family=2, type=1, proto=0, laddr=('0.0.0.0', 8080)> <sys>:0: ResourceWarning: unclosed <socket.socket fd=6, family=10, type=2, proto=0, laddr=('::', 4433, 0, 0)> <sys>:0: ResourceWarning: unclosed <socket.socket fd=5, family=2, type=2, proto=0, laddr=('0.0.0.0', 4433)> ``` ### Description ``` from langgraph.graph import CompiledStateGraph ``` ### System Info ``` System Information ------------------ > OS: Linux > OS Version: #6-Ubuntu SMP PREEMPT_DYNAMIC Tue Oct 7 13:34:17 UTC 2025 > Python Version: 3.13.7 (main, Aug 20 2025, 22:17:40) [GCC 15.2.0] Package Information ------------------- > langchain_core: 1.0.4 > langchain: 1.0.5 > langchain_community: 0.4.1 > langsmith: 0.4.42 > langchain_classic: 1.0.0 > langchain_google_genai: 3.0.2 > langchain_neo4j: 0.6.0 > langchain_ollama: 1.0.0 > langchain_postgres: 0.0.16 > langchain_text_splitters: 1.0.0 > langgraph_api: 0.4.28 > langgraph_cli: 0.4.7 > langgraph_runtime_inmem: 0.14.1 > langgraph_sdk: 0.2.9 Optional packages not installed ------------------------------- > langserve Other Dependencies ------------------ > aiohttp: 3.13.2 > asyncpg: 0.30.0 > blockbuster: 1.5.25 > click: 8.3.0 > cloudpickle: 3.1.2 > cryptography: 44.0.3 > dataclasses-json: 0.6.7 > filetype: 1.2.0 > google-ai-generativelanguage: 0.9.0 > httpx: 0.28.1 > httpx-sse: 0.4.3 > jsonpatch: 1.33 > jsonschema-rs: 0.29.1 > langgraph: 1.0.3 > langgraph-checkpoint: 3.0.1 > neo4j: 5.28.2 > neo4j-graphrag: 1.10.1 > numpy: 2.3.4 > ollama: 0.6.0 > opentelemetry-api: 1.38.0 > opentelemetry-sdk: 1.38.0 > orjson: 3.11.4 > packaging: 25.0 > pgvector: 0.3.6 > psycopg: 3.2.12 > psycopg-pool: 3.2.7 > pydantic: 2.12.4 > pydantic-settings: 2.12.0 > pyjwt: 2.10.1 > pytest: 9.0.0 > python-dotenv: 1.2.1 > pyyaml: 6.0.3 > PyYAML: 6.0.3 > requests: 2.32.5 > requests-toolbelt: 1.0.0 > sqlalchemy: 2.0.44 > SQLAlchemy: 2.0.44 > sse-starlette: 2.1.3 > starlette: 0.49.3 > structlog: 25.5.0 > tenacity: 9.1.2 > truststore: 0.10.4 > typing-extensions: 4.15.0 > uvicorn: 0.38.0 > watchfiles: 1.1.1 > zstandard: 0.25.0 ```
yindo added the bugpending labels 2026-02-20 17:42:54 -05:00
yindo closed this issue 2026-02-20 17:42:54 -05:00
Author
Owner

@khteh commented on GitHub (Nov 12, 2025):

langgraph.graph.state

@khteh commented on GitHub (Nov 12, 2025): `langgraph.graph.state`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#1051