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
Installing LangChain with pip, uv or Colab
The video sets the project up with uv. uv init turns the folder into a project: it writes pyproject.toml, which records the Python version and, later, every package; a .python-version file; and a starter main.py. uv venv then creates the virtual environment in a .venv folder, and the activate script inside it switches the terminal to that environment. The video runs the Windows form, .venv\Scripts\activate.
With the environment active, the video lists the libraries in a requirements.txt file, outside the .venv folder: langchain, langchain-community, langchain-openai, langchain-groq, python-dotenv and langchain-google-genai, with no versions. uv add -r requirements.txt installs them all, the uv form of pip install -r requirements.txt, and uv writes each installed version into pyproject.toml, so you can see which version the project is on. uv add followed by one name adds a single library.
You need Python 3.12 or later. LangChain 1.4 runs on 3.10, but the retrieval lessons use numpy 2.5.3, which needs 3.12. Check yours with python --version. Then pick the tab that fits how you work. pip is the plain way. uv follows the steps from the video. Colab needs nothing installed on your machine. Unlike the video, the tabs pin each version, the ones every lesson was run with.
pip install "langchain==1.4.2" "langchain-groq==1.1.3" "python-dotenv==1.2.3"Whichever tab you used, 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.
Check the install
Check which version Python finds. 1.4.2 is the langchain you pinned, and 1.6.3 is langchain-core, installed with it.
from importlib.metadata import version
print(version("langchain"))
print(version("langchain-core"))1.4.2 1.6.3
The documents lesson and the MCP lesson install what they need when they need it: a text splitter, numpy and MCP support.
Get a free Groq keyRecommended
The video creates three keys, one each from Google AI Studio, Groq and OpenAI, and pastes them into a .env file in the project folder. It also runs uv add ipykernel, which lets a Jupyter notebook use the environment. This course needs one key, Groq's.
Most teaching lessons show a real model call to Groq's free tier, and the output you see is that real reply. Get a free key to run them yourself. A few lessons that teach a mechanic a real model cannot produce on cue (a deliberate validation error, a forced retry) use a small written stand-in instead; each says so.
| 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" |
| OpenAI | Paid, platform.openai.com/api-keys | OPENAI_API_KEY | langchain-openai, "openai:gpt-4.1-mini" |
The video clips were recorded with the models available then, such as gpt-5 and qwen/qwen3-32b. On these pages every example runs on Groq's free openai/gpt-oss-120b, the model the whole course uses, so you can reproduce each output. Any model string in the table works in its place.
Set the key. Groq is shown here; the install tabs above already added langchain-groq.
export GROQ_API_KEY=gsk_...Keeping the key in a .env file
export and $env: set the key for that terminal window only. Close it, and the next window starts without the key. To keep it, save it once in a file named .env in your project folder:
GROQ_API_KEY=gsk_...Python does not read that file on its own. The python-dotenv package, installed above, does. Start each script with these two lines, before any model is created. The examples in later lessons leave them out, so add them at the top of each one if you keep your key in .env:
from dotenv import load_dotenv
load_dotenv() # copies the keys in .env into the environmentload_dotenv() finds the .env file next to your script, even when you run it from another folder, and it leaves alone a key you already set with export. Add .env to your .gitignore so the key never ends up in a Git repository. In Colab you do not need this: the Secrets panel above keeps the key for you.
Check the key with a real call
With the key set, one call reaches Groq and comes back with a real reply.
from langchain.chat_models import init_chat_model
model = init_chat_model("groq:openai/gpt-oss-120b", temperature=0)
print(model.invoke("In one sentence, what is LangChain?").text)LangChain is a framework that enables developers to build applications powered by large language models by chaining together prompts, models, and external tools in a modular, programmable workflow.
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.