Last modified: Jun 10, 2026

Install LangGraph in Python Guide

LangGraph is a powerful library for building stateful, multi-actor applications with large language models. It extends LangChain by adding graph-based execution flows.

This guide shows you how to install LangGraph in Python. We cover prerequisites, installation steps, verification, and common issues.

You need Python 3.8 or higher. We recommend using a virtual environment to avoid package conflicts.

Prerequisites

First, ensure Python is installed. Open your terminal and run:


python --version

You should see Python 3.8 or later. If not, download Python from the official website.

Next, install pip, the Python package manager. Most Python installations include it. Verify with:


pip --version

If pip is missing, install it using the official get-pip.py script.

Create a Virtual Environment

A virtual environment keeps your LangGraph installation isolated. This prevents conflicts with other projects.

Create one with:


python -m venv langgraph_env

Activate it. On Windows:


langgraph_env\Scripts\activate

On macOS/Linux:


source langgraph_env/bin/activate

Your prompt will change to show the environment name. This means it is active.

Install LangGraph via pip

The simplest way to install LangGraph is with pip. Run this command in your terminal:


pip install langgraph

Pip will download LangGraph and its dependencies. This includes langchain-core and pydantic.

For the latest features, install the development version from GitHub:


pip install git+https://github.com/langchain-ai/langgraph.git

But the stable pip version is best for most users.

Verify the Installation

Check that LangGraph installed correctly. Open a Python interpreter:


python

Then run this import test:


# Import LangGraph to verify installation
import langgraph
print(langgraph.__version__)

You should see a version number like 0.0.10. If no error appears, the installation succeeded.

To confirm the package location:


# Check where LangGraph is installed
print(langgraph.__file__)

This shows the file path. It confirms the library is accessible.

Install Optional Dependencies

LangGraph works with various LLM providers. You may need extra packages.

For OpenAI models, install the LangChain OpenAI integration:


pip install langchain-openai

For Anthropic models:


pip install langchain-anthropic

These integrations let you use LangGraph with your preferred LLM.

Basic Example After Installation

Test your setup with a simple graph. Create a file test_graph.py:


# Import necessary modules
from langgraph.graph import StateGraph, END

# Define a simple state
class MyState(dict):
    pass

# Create a graph builder
builder = StateGraph(MyState)

# Add a node that returns a message
def hello_node(state):
    return {"message": "Hello from LangGraph!"}

builder.add_node("hello", hello_node)
builder.set_entry_point("hello")
builder.add_edge("hello", END)

# Compile and run
graph = builder.compile()
result = graph.invoke({})
print(result)

Run the script:


python test_graph.py

Output should be:


{'message': 'Hello from LangGraph!'}

This confirms LangGraph works. You built a graph, executed it, and got a result.

Troubleshooting Common Issues

If installation fails, check your internet connection. Pip needs network access.

A Permission denied error means you need admin rights. Use --user flag:


pip install --user langgraph

Or activate your virtual environment and retry.

If you see ModuleNotFoundError: No module named 'langgraph', you installed in a different environment. Activate the correct one.

Version conflicts happen with older packages. Upgrade pip first:


pip install --upgrade pip

Then install LangGraph again.

Install in Jupyter Notebook

For data scientists, install LangGraph in a Jupyter environment. Use the magic command:


!pip install langgraph

Then import it in your notebook cells. This works for Google Colab too.

For a persistent install in a conda environment:


conda install -c conda-forge langgraph

But pip is the recommended method.

Upgrade LangGraph

Keep LangGraph updated for new features. Upgrade with:


pip install --upgrade langgraph

Check the current version after upgrade:


import langgraph
print(langgraph.__version__)

Always review the changelog before upgrading. Breaking changes may occur.

Uninstall LangGraph

To remove LangGraph, use pip:


pip uninstall langgraph

Answer y to confirm. This removes the package and its dependencies if no other package needs them.

If you used a virtual environment, you can delete the entire environment folder to clean everything.

Conclusion

Installing LangGraph in Python is straightforward. You need Python 3.8+, a virtual environment, and the pip install langgraph command.

We verified the installation with a simple import and a basic graph example. You also learned how to troubleshoot common errors and upgrade the library.

Now you are ready to build stateful LLM applications with LangGraph. Explore graphs, nodes, and edges to create complex workflows.

For more advanced usage, check the official LangGraph documentation and tutorials.