Skip to main content

How to Install LangChain in Python with uv

· 10 min read
Jagdish Kumawat
Founder @ Dewiride

LangChain comes as several Python packages: langchain itself, and one integration package for each model provider, such as langchain-anthropic for Claude. With uv, one command installs LangChain together with the integration you need. This guide installs LangChain 1.5.2 with its Claude integration on Python 3.14, looks at what the command brought in, and shows the trap of a project that still allows Python 3.10, where uv quietly picks an older LangChain.

Syntax​

Syntax
uv add "langchain[<provider>]"
PartWhat it means
uv addAdds a package to the project: uv writes it into pyproject.toml, records the exact versions in uv.lock and installs them into the project's .venv folder
langchainLangChain's main package, with create_agent and init_chat_model
[<provider>]An extra: an optional group of packages that comes along. [anthropic] adds langchain-anthropic, the integration for Claude
The quotesKeep the square brackets away from your shell, which would otherwise read them as a file pattern

LangChain 1.5.2 lists these extras in its package information: anthropic, aws, azure-ai, baseten, community, deepseek, fireworks, google-genai, google-vertexai, groq, huggingface, mcp, meta, mistralai, ollama, openai, perplexity, together and xai. LangChain's install page shows the same result in two steps, uv add langchain and then uv add langchain-anthropic, under the note "Requires Python 3.11+".

The Example​

A new project called langchain-app gets LangChain with the Claude integration. A second project, python310-app, is made for Python 3.10 to show what happens when a project allows a Python version that the newest LangChain no longer supports.

Prerequisites​

  • uv. This guide uses uv 0.13.10. uv downloads Python 3.14 by itself if your computer doesn't have it.

Step 1: Create a Python 3.14 Project​

Terminal
uv init --python 3.14 --no-package langchain-app
cd langchain-app
Output
Initialized project `langchain-app` at `/Users/you/source/langchain-app`

The terminal after uv init --python 3.14 --no-package langchain-app: Initialized project langchain-app.

--python 3.14 makes the project require Python 3.14 or later and pins it to 3.14. --no-package leaves out the build system, so the project is a plain folder with its code in main.py, rather than a package in a src folder. Python 3.14 is the newest version that LangChain's packages list as supported: LangChain 1.5.2 declares Python 3.11 to 3.14.

Step 2: Add LangChain with the Claude Integration​

Terminal
uv add "langchain[anthropic]"
Output
Using CPython 3.14.10
Creating virtual environment at: .venv
Resolved 46 packages in 11ms
Installed 44 packages in 84ms
+ annotated-types==0.8.0
+ anthropic==2.17.0
+ anyio==4.16.0
+ certifi==2026.11.20
+ charset-normalizer==3.5.3
+ distro==1.9.0
+ docstring-parser==0.18.0
+ h11==0.16.0
+ httpcore==1.0.9
+ httpcore2==2.18.0
+ httpx==0.29.0
+ httpx2==2.18.0
+ idna==3.21
+ jiter==0.19.0
+ jsonpatch==1.48
+ jsonpointer==3.12
+ langchain==1.5.2
+ langchain-anthropic==1.9.0
+ langchain-core==1.9.1
+ langchain-protocol==0.0.22
+ langgraph==1.2.25
+ langgraph-checkpoint==4.3.2
+ langgraph-prebuilt==1.1.3
+ langgraph-sdk==0.4.14
+ langsmith==0.16.8
+ opentelemetry-api==1.46.1
+ orjson==3.13.0
+ ormsgpack==1.13.1
+ packaging==26.4
+ pydantic==2.14.4
+ pydantic-core==2.50.5
+ pyyaml==6.0.4
+ requests==2.34.2
+ requests-toolbelt==1.0.0
+ sniffio==1.3.1
+ tenacity==9.2.1
+ truststore==0.10.5
+ typing-extensions==4.16.0
+ typing-inspection==0.4.5
+ urllib3==2.8.0
+ uuid-utils==0.20.0
+ websockets==17.4
+ xxhash==4.1.0
+ zstandard==0.26.0

The terminal after uv add "langchain[anthropic]": uv uses CPython 3.14.10, creates .venv, resolves 46 packages and installs 44, including langchain 1.5.2, langchain-anthropic 1.9.0, langchain-core 1.9.1, anthropic 2.17.0, langgraph 1.2.25 and langsmith 0.16.8.

The first two lines are uv choosing Python 3.14.10 and creating the project's virtual environment, the .venv folder the packages go into. Among the 44 packages, these are the ones you'll meet in LangChain code:

PackageVersionWhat it is
langchain1.5.2LangChain itself
langchain-core1.9.1The building blocks every LangChain package shares, such as messages and tools
langchain-anthropic1.9.0The Claude integration, from the [anthropic] extra
anthropic2.17.0Anthropic's own Python library, which langchain-anthropic uses to call Claude
langgraph1.2.25The engine that runs LangChain's agents
langsmith0.16.8The client for LangSmith tracing, which stays off until you turn it on

uv also wrote the dependency into pyproject.toml:

pyproject.toml
[project]
name = "langchain-app"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.14"
dependencies = [
"langchain[anthropic]>=1.5.2",
]

The pyproject.toml of langchain-app in a macOS-style code window: requires-python is >=3.14 and the only dependency is langchain[anthropic]>=1.5.2.

>=1.5.2 is a lower bound: this version or any newer one. The exact versions uv picked are recorded in uv.lock, so the project installs the same set on any computer.

Step 3: See What the Extra Brought In​

uv tree prints the project's dependencies as a tree, and --depth limits how many levels it shows:

Terminal
uv tree --depth 1
uv tree --depth 2
Output
Resolved 46 packages in 5ms
langchain-app v0.1.0
└── langchain[anthropic] v1.5.2
Resolved 46 packages in 5ms
langchain-app v0.1.0
└── langchain[anthropic] v1.5.2
├── langchain-core v1.9.1
├── langgraph v1.2.25
├── pydantic v2.14.4
└── langchain-anthropic v1.9.0 (extra: anthropic)

The terminal after uv tree --depth 1 and --depth 2: the project depends on langchain[anthropic] v1.5.2, which depends on langchain-core v1.9.1, langgraph v1.2.25, pydantic v2.14.4 and, from the anthropic extra, langchain-anthropic v1.9.0.

At the first level, the project has a single dependency. One level down, langchain needs langchain-core, langgraph and pydantic in every project, and langchain-anthropic is marked (extra: anthropic): it's there only because of the [anthropic] in the command.

A Project That Allows Python 3.10 Gets an Older LangChain​

LangChain 1.5 needs Python 3.11 or later, while LangChain 1.4.10 still supported Python 3.10. A project made for Python 3.10 shows what uv does with that:

Terminal
uv init --python 3.10 --no-package python310-app
cd python310-app
uv add "langchain[anthropic]"
Output
Initialized project `python310-app` at `/Users/you/source/python310-app`
Using CPython 3.10.11 interpreter at: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
Creating virtual environment at: .venv
Resolved 58 packages in 356ms
Prepared 17 packages in 687ms
Installed 45 packages in 86ms
+ annotated-types==0.8.0
+ anthropic==2.17.0
+ anyio==4.16.0
+ certifi==2026.11.20
+ charset-normalizer==3.5.3
+ distro==1.9.0
+ docstring-parser==0.18.0
+ exceptiongroup==1.3.2
+ h11==0.16.0
+ httpcore==1.0.9
+ httpcore2==2.14.0
+ httpx==0.29.0
+ httpx2==2.14.0
+ idna==3.21
+ jiter==0.18.0
+ jsonpatch==1.46
+ jsonpointer==3.12
+ langchain==1.4.10
+ langchain-anthropic==1.7.10
+ langchain-core==1.7.7
+ langchain-protocol==0.0.22
+ langgraph==1.2.25
+ langgraph-checkpoint==4.3.2
+ langgraph-prebuilt==1.1.3
+ langgraph-sdk==0.4.14
+ langsmith==0.14.17
+ opentelemetry-api==1.46.1
+ orjson==3.13.0
+ ormsgpack==1.12.2
+ packaging==26.4
+ pydantic==2.14.4
+ pydantic-core==2.50.5
+ pyyaml==6.0.4
+ requests==2.34.2
+ requests-toolbelt==1.0.0
+ sniffio==1.3.1
+ tenacity==9.2.1
+ truststore==0.10.5
+ typing-extensions==4.16.0
+ typing-inspection==0.4.5
+ urllib3==2.8.0
+ uuid-utils==0.20.0
+ websockets==16.1.1
+ xxhash==4.1.0
+ zstandard==0.25.0

The terminal after uv add "langchain[anthropic]" in a Python 3.10 project: uv uses CPython 3.10.11 and installs langchain 1.4.10, langchain-anthropic 1.7.10, langchain-core 1.7.7 and langsmith 0.14.17.

There's no error and no warning, but the list says langchain==1.4.10, langchain-anthropic==1.7.10 and langchain-core==1.7.7. uv's resolution documentation explains why: it tries "to choose the latest compatible version for each supported Python version". This project allows Python 3.10, the newest LangChain for 3.10 is 1.4.10, and this project's environment runs 3.10, so that's the version it got, and pyproject.toml now says "langchain[anthropic]>=1.4.10".

To move the project to Python 3.14, open pyproject.toml and change requires-python = ">=3.10" to requires-python = ">=3.14". Then pin the project to 3.14 and add LangChain again with the version you want as the lower bound:

Terminal
uv python pin 3.14
uv add "langchain[anthropic]>=1.5.2"
Output
Updated `.python-version` from `3.10` -> `3.14`
Using CPython 3.14.10
Removed virtual environment at: .venv
Creating virtual environment at: .venv
Resolved 46 packages in 10ms
Installed 44 packages in 89ms

The terminal after uv python pin 3.14 and uv add "langchain[anthropic]>=1.5.2": the pin moves from 3.10 to 3.14, uv recreates .venv on CPython 3.14.10 and installs langchain 1.5.2, langchain-anthropic 1.9.0 and langchain-core 1.9.1.

uv replaced the Python 3.10 environment with a 3.14 one, and the list of installed packages, shortened above, now reads langchain==1.5.2, langchain-anthropic==1.9.0 and langchain-core==1.9.1, the same as in Step 2.

Common Mistakes​

MistakeWhat happensDo this instead
Leaving out the quotes in zsh: uv add langchain[anthropic]zsh:1: no matches found: langchain[anthropic], and uv never runsQuote it: uv add "langchain[anthropic]"
Installing langchain without an integrationLangChain installs, but a call to Claude fails with ImportError: Initializing ChatAnthropic requires the langchain-anthropic package. Please install it with `pip install langchain-anthropic`Run uv add langchain-anthropic in the project, or use the [anthropic] extra
Keeping a project that allows Python 3.10uv installs LangChain 1.4.10 without a warningRequire Python 3.14 in pyproject.toml, pin it, and add LangChain with >=1.5.2

Troubleshooting​

SymptomLikely causeFix
ImportError: Initializing ChatAnthropic requires the langchain-anthropic packageThe project has langchain but no Claude integrationuv add langchain-anthropic; in a project made with uv add langchain it installed 5 packages, among them langchain-anthropic==1.9.0 and anthropic==2.17.0
The install list shows langchain==1.4.10The project allows Python 3.10Change requires-python, run uv python pin 3.14 and add "langchain[anthropic]>=1.5.2"

FAQ​

Do I need langchain-anthropic if I use another model?​

No. Each provider has its own integration package, and the extra has the provider's name: uv add "langchain[openai]" for OpenAI, for example. One project can have several extras.

Can I use pip instead of uv?​

Yes. LangChain's install page shows pip install -U langchain and pip install -U langchain-anthropic next to the uv commands. This guide uses uv because it also creates the project, picks the Python version and records exact versions in uv.lock.

Is LangChain free?​

Yes. LangChain is open source under the MIT license. What costs money is the model it calls: Claude bills each request by its tokens.

Conclusion​

uv add "langchain[anthropic]" installed LangChain 1.5.2, langchain-core 1.9.1 and the Claude integration, langchain-anthropic 1.9.0, in a Python 3.14 project, and uv tree --depth 2 showed that the integration came from the [anthropic] extra. In a project that allowed Python 3.10, the same command installed LangChain 1.4.10 without a warning, until the project required Python 3.14.

Additional Resources​