Module 1 Lesson 2: Installing LangChain
The core installation. Learning about LangChain's modular package structure and how to install the base library.
Installing LangChain
LangChain is not just one library; it is a Chain of Ecosystems. In early 2024, LangChain moved to a modular structure to make it lighter and faster.
1. Modular Structure
As and AI developer, you should understand the three main parts of LangChain:
langchain-core: The base abstractions (interfaces) for models, prompts, and chains.langchain-community: Third-party integrations (Postgres, Pinecone, specific search engines).langchain: The higher-level chains and systems that tie everything together.
2. The Basic Installation
To get started with the standard features, run:
pip install langchain
This will automatically install langchain-core and common utility libraries.
3. Best Practice: requirements.txt
Never install packages manually without recording them. Create a file named requirements.txt and add:
langchain
Then install using:
pip install -r requirements.txt
4. Verification
To ensure LangChain is installed correctly, you can run a quick check in Python:
import langchain
print(f"LangChain version: {langchain.__version__}")
Key Takeaways
- LangChain is Modular; you only install what you need.
pip install langchainis the entry point for most users.- Use a requirements.txt file to manage your project's history.
- Installation verification is a crucial step in every setup.