Import "langgraph.graph" could not be resolved - Pylance reportMissingImports #59

Closed
opened 2026-02-20 17:24:20 -05:00 by yindo · 3 comments
Owner

Originally created by @tedjames on GitHub (Apr 4, 2024).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.

Example Code

from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage
from langgraph.graph import END, MessageGraph

model = ChatOpenAI(temperature=0)

graph = MessageGraph()

graph.add_node("oracle", model)
graph.add_edge("oracle", END)

graph.set_entry_point("oracle")

runnable = graph.compile()

runnable.invoke(HumanMessage("What is 1 + 1?"))

Error Message and Stack Trace (if applicable)

Import "langgraph.graph" could not be resolved - Pylance reportMissingImports

Description

Posting here since no one responded to my discussion thread earlier this week... I am trying to install langgraph into a new project but am constantly seeing this Import "langgraph.graph" could not be resolved - Pylance reportMissingImports error.

I've tried installing with both poetry and pip directly to no avail. I've also tried using a few different interpreters but nothing seems to work... Langchain imports just fine but Langgraph does not for some reason.

I'm mostly a JS/TS guy so I do apologize in advanced if I'm missing something blatantly obvious here! Would appreciate any help getting this to work :)

Screenshot 2024-03-31 at 5 00 42 PM Screenshot 2024-03-31 at 12 02 44 AM

System Info

System Information

OS: Darwin
OS Version: Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000
Python Version: 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)]

Package Information

langchain_core: 0.1.36
langchain: 0.1.13
langchain_community: 0.0.29
langsmith: 0.1.38
langchain_openai: 0.1.1
langchain_text_splitters: 0.0.1
langgraph: 0.0.30

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

langserve

Originally created by @tedjames on GitHub (Apr 4, 2024). ### Checked other resources - [X] I added a very descriptive title to this issue. - [X] I searched the LangChain documentation with the integrated search. - [X] I used the GitHub search to find a similar question and didn't find it. - [X] I am sure that this is a bug in LangChain rather than my code. ### Example Code from langchain_openai import ChatOpenAI from langchain_core.messages import HumanMessage from langgraph.graph import END, MessageGraph model = ChatOpenAI(temperature=0) graph = MessageGraph() graph.add_node("oracle", model) graph.add_edge("oracle", END) graph.set_entry_point("oracle") runnable = graph.compile() runnable.invoke(HumanMessage("What is 1 + 1?")) ### Error Message and Stack Trace (if applicable) Import "langgraph.graph" could not be resolved - Pylance reportMissingImports ### Description Posting here since no one responded to my discussion thread earlier this week... I am trying to install langgraph into a new project but am constantly seeing this Import "langgraph.graph" could not be resolved - Pylance reportMissingImports error. I've tried installing with both poetry and pip directly to no avail. I've also tried using a few different interpreters but nothing seems to work... Langchain imports just fine but Langgraph does not for some reason. I'm mostly a JS/TS guy so I do apologize in advanced if I'm missing something blatantly obvious here! Would appreciate any help getting this to work :) <img width="764" alt="Screenshot 2024-03-31 at 5 00 42 PM" src="https://github.com/langchain-ai/langgraph/assets/13091675/a0714378-1076-41e3-94ce-5d39f66a6f2d"> <img width="564" alt="Screenshot 2024-03-31 at 12 02 44 AM" src="https://github.com/langchain-ai/langgraph/assets/13091675/8afe9720-fdd4-41cf-b16c-38f12fce2935"> ### System Info System Information ------------------ > OS: Darwin > OS Version: Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000 > Python Version: 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)] Package Information ------------------- > langchain_core: 0.1.36 > langchain: 0.1.13 > langchain_community: 0.0.29 > langsmith: 0.1.38 > langchain_openai: 0.1.1 > langchain_text_splitters: 0.0.1 > langgraph: 0.0.30 Packages not installed (Not Necessarily a Problem) -------------------------------------------------- The following packages were not found: > langserve
yindo closed this issue 2026-02-20 17:24:20 -05:00
Author
Owner

@roninio commented on GitHub (Apr 5, 2024):

not a bug working on my end.
did you try to run the code? it could by your Pylance is using a different python environment.

@roninio commented on GitHub (Apr 5, 2024): not a bug working on my end. did you try to run the code? it could by your Pylance is using a different python environment.
Author
Owner

@asterism45 commented on GitHub (Apr 6, 2024):

I had a similar error, but in my case it was because I had created a file named langgraph.py by myself, and rewriting the file name solved the problem!

@asterism45 commented on GitHub (Apr 6, 2024): I had a similar error, but in my case it was because I had created a file named langgraph.py by myself, and rewriting the file name solved the problem!
Author
Owner

@tedjames commented on GitHub (Apr 8, 2024):

not a bug working on my end. did you try to run the code? it could by your Pylance is using a different python environment.

Yep that did it... new to Python and VSCode. Was trying to install modules to the wrong python interpreter and also had vscode pointing to the wrong one too. Got the path using poetry run which python, copied/pasted that into vscode and it did the trick! Thank you

@tedjames commented on GitHub (Apr 8, 2024): > not a bug working on my end. did you try to run the code? it could by your Pylance is using a different python environment. Yep that did it... new to Python and VSCode. Was trying to install modules to the wrong python interpreter and also had vscode pointing to the wrong one too. Got the path using poetry run which python, copied/pasted that into vscode and it did the trick! Thank you
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#59