Installation and setup
LangChain installs from PyPI with one pip command: the langchain package brings the framework, its core types, and the runtime that runs its agents.
Last updated: 27 Sep, 2026 · LangChain 1.4
The langchain package brings langchain-core, which holds the message types and the base classes every model builds on, and langgraph, which runs the agent loop.
Installing the langchain package
pip install "langchain==1.4.2"In a notebook, prefix it with a percent sign: %pip install "langchain==1.4.2".
Check the install
Check which version Python finds:
from importlib.metadata import version
print(version("langchain"))
print(version("langchain-core"))Reading the version numbers
- 1.4.2 is the
langchainversion you pinned. - 1.6.3 is
langchain-core, pulled in as a dependency; it holds the message types and the base classes every model builds on.
Lessons 26 and 29 install what they need when they need it: a text splitter, numpy and MCP support.
Keys, for when you want a hosted modelOptional
Every lesson runs on a stand-in model you write in lesson 3. To use a hosted model instead, install its provider package and set its key as an environment variable. The real-model lesson makes the switch with init_chat_model.
| Provider | Key | Variable | Package and model string |
|---|---|---|---|
| Groq | Free, console.groq.com/keys | GROQ_API_KEY | langchain-groq, "groq:openai/gpt-oss-120b" |
| Gemini | Free, aistudio.google.com/apikey | GOOGLE_API_KEY | langchain-google-genai, "google_genai:gemini-2.5-flash" |
| OpenRouter | Free models end in :free, openrouter.ai/keys | OPENROUTER_API_KEY | langchain-openrouter, "openrouter:google/gemma-4-31b-it:free" |
Install a provider package and set its key. Groq is shown here.
pip install "langchain-groq==1.1.3"export GROQ_API_KEY=gsk_...pip install langchain with no version pulls whatever is newest, and an API that moved can break a lesson that ran yesterday.Related
- Previous: LangChain overview
- Next: Messages: a conversation as a list
- Reference: Install LangChain
- Run the version check and confirm
langchainis 1.4.2. - Run
pip show langchainand findlanggraphin itsRequiresline. - Import
from langchain.messages import HumanMessageand confirm no error.
Little by little, you're building something great.