LangChain (YT style)LangChain 1.4 · Python 3.12+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
46 small wins to finish your pathNext lesson →

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

Creating a project and a virtual environment with uv · from the Updated LangChain Version V1 Crash Course · 7:03 to 10:29

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.

Installing the libraries with uv add · from the Updated LangChain Version V1 Crash Course · 10:25 to 14:09

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.

Example
from importlib.metadata import version

print(version("langchain"))
print(version("langchain-core"))

The documents lesson and the MCP lesson install what they need when they need it: a text splitter, numpy and MCP support.

API keys in a .env file and ipykernel · from the Updated LangChain Version V1 Crash Course · 14:06 to 16:17

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.

ProviderKeyVariablePackage and model string
GroqFree, console.groq.com/keysGROQ_API_KEYlangchain-groq, "groq:openai/gpt-oss-120b"
GeminiFree, aistudio.google.com/apikeyGOOGLE_API_KEYlangchain-google-genai, "google_genai:gemini-2.5-flash"
OpenRouterFree models end in :free, openrouter.ai/keysOPENROUTER_API_KEYlangchain-openrouter, "openrouter:google/gemma-4-31b-it:free"
OpenAIPaid, platform.openai.com/api-keysOPENAI_API_KEYlangchain-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:

bash
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:

python
from dotenv import load_dotenv

load_dotenv()   # copies the keys in .env into the environment

load_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.

ExampleAPI key
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)
Watch out. Pin the version. pip install langchain with no version pulls whatever is newest, and an API that moved can break a lesson that ran yesterday.
Try it yourself
  • Run the version check and confirm langchain is 1.4.2.
  • Run pip show langchain and find langgraph in its Requires line.
  • Import from langchain.messages import HumanMessage and confirm no error.

Little by little, you're building something great.