Skip to content

SOP-001: Environment Setup

Document Control

PropertyValue
SOP ID001
TitleEnvironment Setup
Version1.0
StatusActive
ComplexityEasy

Purpose

Install all required dependencies and configure the development environment for building self-evolving agents.

Prerequisites

  • Python 3.10 or higher
  • pip package manager
  • Terminal/command line access
  • OpenAI account with API access

Procedure Flowchart

┌─────────────────────────────────────────────────────────────────────┐
│                    ENVIRONMENT SETUP FLOW                            │
├─────────────────────────────────────────────────────────────────────┤
│                                                                      │
│  ┌─────────────────┐                                                │
│  │  Check Python   │                                                │
│  │    Version      │                                                │
│  └────────┬────────┘                                                │
│           │                                                          │
│           ▼                                                          │
│  ┌─────────────────┐     ┌─────────────────┐                        │
│  │ Install Core    │────►│ Install Optional│                        │
│  │  Dependencies   │     │  Dependencies   │                        │
│  └────────┬────────┘     └────────┬────────┘                        │
│           │                       │                                  │
│           └───────────┬───────────┘                                  │
│                       ▼                                              │
│           ┌─────────────────┐                                       │
│           │  Create .env    │                                       │
│           │     File        │                                       │
│           └────────┬────────┘                                       │
│                    │                                                 │
│                    ▼                                                 │
│           ┌─────────────────┐                                       │
│           │    Verify       │                                       │
│           │  Installation   │                                       │
│           └─────────────────┘                                       │
│                                                                      │
└─────────────────────────────────────────────────────────────────────┘

Step-by-Step Procedure

Step 1: Verify Python Version

bash
python --version
# Expected: Python 3.10.x or higher

WARNING

Python 3.9 and below are not supported due to type hint syntax requirements.

Step 2: Create Project Directory

bash
mkdir self-evolving-agents
cd self-evolving-agents
bash
python -m venv venv

# Windows
venv\Scripts\activate

# macOS/Linux
source venv/bin/activate

Step 4: Install Core Dependencies

bash
pip install --upgrade openai openai-agents pydantic pandas python-dotenv

Package Descriptions:

PackageVersionPurpose
openaiLatestOpenAI API client
openai-agentsLatestAgents SDK for building agents
pydanticLatestData validation for PromptVersionEntry
pandasLatestDataset handling
python-dotenvLatestEnvironment variable management

Step 5: Install Optional Dependencies (GEPA)

bash
pip install gepa litellm
PackagePurpose
gepaGenetic-Pareto prompt optimization
litellmMulti-model support for GEPA

Step 6: Configure Environment Variables

Create .env file in project root:

bash
# .env
OPENAI_API_KEY=sk-your-api-key-here

Step 7: Create Configuration File

Create config.py:

python
import os
from dotenv import load_dotenv

load_dotenv()

# API Configuration
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")

# Model Configuration
DEFAULT_MODEL = "gpt-5"
EVAL_MODEL = "gpt-4.1"

# Optimization Thresholds
LENIENT_PASS_RATIO = 0.75
LENIENT_AVERAGE_THRESHOLD = 0.85
MAX_OPTIMIZATION_RETRIES = 3

Step 8: Verify Installation

Create verify_setup.py:

python
import os
from dotenv import load_dotenv
from openai import OpenAI

load_dotenv()

def verify():
    # Check API key
    api_key = os.getenv("OPENAI_API_KEY")
    if not api_key:
        print("❌ OPENAI_API_KEY not found in .env")
        return False

    # Test API connection
    try:
        client = OpenAI(api_key=api_key)
        models = client.models.list()
        print("✅ OpenAI API connection successful")
        print(f"✅ Found {len(list(models))} available models")
        return True
    except Exception as e:
        print(f"❌ API connection failed: {e}")
        return False

if __name__ == "__main__":
    verify()

Run verification:

bash
python verify_setup.py

Expected Output:

✅ OpenAI API connection successful
✅ Found X available models

Verification Checklist

  • [ ] Python 3.10+ installed and verified
  • [ ] Virtual environment created and activated
  • [ ] Core dependencies installed (openai, openai-agents, pydantic, pandas, python-dotenv)
  • [ ] Optional dependencies installed (gepa, litellm) if using GEPA
  • [ ] .env file created with valid API key
  • [ ] Verification script runs successfully

Troubleshooting

Issue: ModuleNotFoundError: No module named 'openai'

Solution: Ensure virtual environment is activated and reinstall:

bash
pip install --force-reinstall openai

Issue: API key not found

Solution: Verify .env file location and format:

bash
# Check file exists
ls -la .env

# Check content (careful not to expose key)
head -c 20 .env

Issue: SSL Certificate errors

Solution: Update certificates:

bash
pip install --upgrade certifi

See Also

Based on OpenAI Cookbook - Bain & OpenAI Collaboration