Installing LangChain and Its Integrations
LangChain separates its core interfaces from provider integrations. Installing langchain alone does not install every model adapter or document loader.
#Create an isolated environment
bashpython -m venv .venv source .venv/bin/activate python -m pip install langchain langchain-openai python-dotenv python -m pip check
On Windows PowerShell, activate with .venv\Scripts\Activate.ps1. Use a Python version supported by the package release you install.
| Package | Purpose |
|---|---|
langchain-core | Messages, prompts, runnable interfaces |
langchain-openai | OpenAI integration |
langchain-anthropic | Anthropic integration |
langchain-google-genai | Gemini integration |
langchain-community | Additional community integrations |
langchain-chroma | Chroma vector-store integration |
langgraph | Stateful graph workflows |
langsmith | Tracing and evaluation integration |
Install only the integrations you use. A missing langchain_openai import usually means the provider package is absent from the active environment, not that the core package is broken.
#Separate installation from provider access
Check imports without making a model request:
bashpython -c "from langchain_core.prompts import ChatPromptTemplate; print('Core import OK')"
Configure OPENAI_API_KEY and a supported OPENAI_MODEL only when provider execution is authorized. Keep secrets out of Git. Load environment configuration before creating a client; it does not need to precede every Python import.
#Lock a working environment
After resolving compatible versions, save an exact lockfile or a reviewed pip freeze output. Do not combine old 0.x tutorial imports with a current major version without checking migration notes. Validate dependency compatibility before upgrading shared packages such as Pydantic.
Tracing is optional and can transmit prompts and outputs. Configure redaction, consent and retention before enabling it for private data; do not assume a hosted service is automatically free or suitable for every workload.