Lesson 3 of 20

Environment Setup

Package Management

3 min read

pip is Python's package installer. It lets you install libraries from the Python Package Index (PyPI), which hosts over 500,000 packages.

Installing Packages

# Make sure your virtual environment is activated first!

# Install a single package
pip install requests

# Install a specific version
pip install openai==1.5.0

# Install multiple packages
pip install langchain openai tiktoken

Common AI Packages

Package Purpose
openai OpenAI API client
anthropic Claude API client
langchain AI agent framework
requests HTTP requests
python-dotenv Load environment variables

requirements.txt

This file lists all your project's dependencies. It's essential for sharing your project.

Creating requirements.txt

# Export all installed packages
pip freeze > requirements.txt

Example requirements.txt:

openai==1.5.0
langchain==0.1.0
python-dotenv==1.0.0
requests==2.31.0

Installing from requirements.txt

pip install -r requirements.txt

Version Specifiers

openai==1.5.0    # Exact version
openai>=1.5.0    # Minimum version
openai>=1.5,<2.0 # Version range
openai~=1.5.0    # Compatible release (>=1.5.0, <1.6.0)

Upgrading Packages

# Upgrade a specific package
pip install --upgrade openai

# Upgrade pip itself
pip install --upgrade pip

Next, we'll learn how to securely manage API keys with environment variables. :::

Quiz

Module 1: Environment Setup

Take Quiz