Chapter 0
15 min read
Section 2 of 175

Development Environment Setup

Prerequisites and Setup

Introduction

A properly configured development environment is essential for building AI agents. This section guides you through setting up Python, Node.js, and the tools you'll need throughout this book.

Why Both Python and Node.js? Python is the primary language for AI/ML work and most agent frameworks. Node.js is used for MCP servers, some tooling, and TypeScript-based agents. Having both ready will serve you well.

Python Environment

Installing Python 3.11+

We recommend Python 3.11 or 3.12 for the best compatibility with modern AI libraries.

⚔install_python.sh
1# macOS (using Homebrew)
2brew install python@3.12
3
4# Ubuntu/Debian
5sudo apt update
6sudo apt install python3.12 python3.12-venv python3-pip
7
8# Windows (using winget)
9winget install Python.Python.3.12
10
11# Verify installation
12python3 --version  # Should show 3.11+ or 3.12+

Setting Up Virtual Environments

Always use virtual environments to isolate project dependencies:

⚔venv_setup.sh
1# Create a project directory
2mkdir agentic-ai-projects
3cd agentic-ai-projects
4
5# Create a virtual environment
6python3 -m venv venv
7
8# Activate it
9# macOS/Linux:
10source venv/bin/activate
11
12# Windows:
13.\venv\Scripts\activate
14
15# Your prompt should now show (venv)
16# Install base packages
17pip install --upgrade pip

Installing Core Dependencies

Create a requirements.txt with the essential packages:

šŸ“requirements.txt
1# LLM APIs
2anthropic>=0.40.0
3openai>=1.50.0
4
5# Agent Frameworks
6langchain>=0.3.0
7langgraph>=0.2.0
8crewai>=0.80.0
9
10# Tools and Utilities
11httpx>=0.27.0
12pydantic>=2.0.0
13python-dotenv>=1.0.0
14
15# Vector Databases (for memory)
16chromadb>=0.5.0
17
18# Development
19pytest>=8.0.0
20black>=24.0.0
21mypy>=1.0.0
22
23# Optional: for web scraping
24beautifulsoup4>=4.12.0
25playwright>=1.40.0
⚔install_deps.sh
1# Install all dependencies
2pip install -r requirements.txt
3
4# Install Playwright browsers (for web automation)
5playwright install chromium

Use pyenv for multiple Python versions

If you work on multiple projects, pyenv lets you switch Python versions easily:brew install pyenv (macOS) or check pyenv-installer for other platforms.

Node.js Setup

Installing Node.js 20+

Node.js is required for MCP servers and some tooling. We recommend Node.js 20 LTS or later.

⚔install_node.sh
1# macOS (using Homebrew)
2brew install node@20
3
4# Ubuntu/Debian (using NodeSource)
5curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
6sudo apt install -y nodejs
7
8# Windows (using winget)
9winget install OpenJS.NodeJS.LTS
10
11# Alternative: Use nvm (Node Version Manager) - Recommended
12# Install nvm first:
13curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
14
15# Then install Node:
16nvm install 20
17nvm use 20
18
19# Verify installation
20node --version  # Should show v20.x.x
21npm --version

Global Packages

⚔npm_globals.sh
1# TypeScript (for typed JavaScript)
2npm install -g typescript ts-node
3
4# MCP CLI tools (when available)
5npm install -g @modelcontextprotocol/sdk
6
7# Development utilities
8npm install -g prettier eslint

IDE Configuration

VS Code with the right extensions provides an excellent experience for agent development:

⚔vscode_extensions.sh
1# Install VS Code extensions from command line
2code --install-extension ms-python.python
3code --install-extension ms-python.vscode-pylance
4code --install-extension bradlc.vscode-tailwindcss
5code --install-extension dbaeumer.vscode-eslint
6code --install-extension esbenp.prettier-vscode
7code --install-extension ms-vscode.vscode-typescript-next

VS Code Settings

Add these to your .vscode/settings.json:

{}.vscode/settings.json
1{
2  "python.defaultInterpreterPath": "./venv/bin/python",
3  "python.formatting.provider": "black",
4  "editor.formatOnSave": true,
5  "python.linting.enabled": true,
6  "python.linting.mypyEnabled": true,
7  "[python]": {
8    "editor.defaultFormatter": "ms-python.black-formatter"
9  },
10  "[typescript]": {
11    "editor.defaultFormatter": "esbenp.prettier-vscode"
12  },
13  "editor.rulers": [88, 120],
14  "files.trimTrailingWhitespace": true
15}

Cursor or Windsurf (AI-Powered)

For an AI-enhanced experience, consider using Cursor or Windsurf:

  • Cursor - Fork of VS Code with built-in AI coding assistance
  • Windsurf - Another AI-powered IDE with agent capabilities

IDE choice doesn't affect the content

All code in this book works with any editor. Use what you're comfortable with.

Docker (Optional)

Docker is useful for sandboxing agent execution and deployment:

⚔docker_setup.sh
1# macOS
2brew install --cask docker
3
4# Ubuntu
5sudo apt install docker.io docker-compose
6sudo usermod -aG docker $USER
7
8# Windows
9winget install Docker.DockerDesktop
10
11# Verify installation
12docker --version
13docker run hello-world

When is Docker essential?

Docker becomes critical when you build coding agents that execute user code. Running untrusted code in containers prevents security issues.

Verify Your Setup

Run this script to verify everything is configured correctly:

šŸverify_setup.py
1#!/usr/bin/env python3
2"""Verify your development environment is ready."""
3
4import sys
5import subprocess
6
7def check_python():
8    version = sys.version_info
9    if version.major >= 3 and version.minor >= 11:
10        print(f"āœ… Python {version.major}.{version.minor}.{version.micro}")
11        return True
12    print(f"āŒ Python {version.major}.{version.minor} (need 3.11+)")
13    return False
14
15def check_package(name: str) -> bool:
16    try:
17        __import__(name)
18        print(f"āœ… {name}")
19        return True
20    except ImportError:
21        print(f"āŒ {name} not installed")
22        return False
23
24def check_node():
25    try:
26        result = subprocess.run(
27            ["node", "--version"],
28            capture_output=True, text=True
29        )
30        version = result.stdout.strip()
31        print(f"āœ… Node.js {version}")
32        return True
33    except FileNotFoundError:
34        print("āŒ Node.js not found")
35        return False
36
37def main():
38    print("\nšŸ” Checking Development Environment...\n")
39
40    all_good = True
41
42    # Check Python
43    print("Python Environment:")
44    all_good &= check_python()
45
46    # Check core packages
47    print("\nCore Packages:")
48    packages = ["anthropic", "openai", "langchain", "pydantic", "httpx"]
49    for pkg in packages:
50        all_good &= check_package(pkg)
51
52    # Check Node
53    print("\nNode.js:")
54    all_good &= check_node()
55
56    # Summary
57    print("\n" + "="*50)
58    if all_good:
59        print("šŸŽ‰ All checks passed! You're ready to build agents.")
60    else:
61        print("āš ļø  Some checks failed. Please install missing components.")
62
63    return 0 if all_good else 1
64
65if __name__ == "__main__":
66    sys.exit(main())
⚔run_verification.sh
1# Save the script and run it
2python verify_setup.py

Summary

Your development environment should now include:

  1. Python 3.11+ with virtual environment
  2. Core packages: anthropic, openai, langchain, pydantic
  3. Node.js 20+ for MCP and tooling
  4. IDE configured with Python and TypeScript support
  5. Docker (optional) for sandboxed execution
Next Step: With your environment ready, let's configure API keys and credentials in the next section.