2. Environment setup

2. Environment setup

Before building an A2A agent, you need a working development environment. This chapter walks you through configuring Python and installing the A2A SDK dependencies.

📋 System requirements

Required

  • Python 3.10+ - Minimum requirement for the A2A SDK
  • Terminal / command prompt - To run commands
  • Git - To clone repositories
  • Network access - To download dependencies

Recommended tools

  • Editor/IDE: Visual Studio Code, PyCharm, or Sublime Text
  • HTTP client: curl, Postman, or similar
  • JSON formatter: For viewing/editing JSON

📥 Clone the sample repository

First, get the official A2A sample code:

# Clone the A2A repository
git clone https://github.com/google/A2A.git -b main --depth 1
cd A2A

This repository contains A2A examples in multiple languages, including Python and JavaScript.

🐍 Python environment setup

Step 1: Create a virtual environment

We strongly recommend using a virtual environment to isolate dependencies:

# Create a virtual environment
python -m venv a2a-env

# Activate it
source a2a-env/bin/activate
# Create a virtual environment
python -m venv a2a-env

# Activate it
a2a-env\\Scripts\\activate

After activation, your prompt should show an (a2a-env) prefix.

Step 2: Upgrade pip

Make sure you have a recent pip:

pip install --upgrade pip

Step 3: Install the A2A SDK dependencies

Install the Python dependencies used by the samples:

# Enter the Python samples directory
cd samples/python

# Install dependencies
pip install -r requirements.txt

# Or, if you use uv
# uv pip install -r requirements.txt

✅ Verify the installation

Test importing the SDK

Verify that the SDK can be imported:

python -c "import a2a; print('A2A SDK import succeeded!')"

If you see the message without errors, the install is working.

Check key dependency versions

python -c "
import sys
print(f'Python: {sys.version}')

try:
    import a2a
    print('✅ A2A SDK: installed')
except ImportError:
    print('❌ A2A SDK: missing')

try:
    import fastapi
    print('✅ FastAPI: installed')
except ImportError:
    print('❌ FastAPI: missing')

try:
    import pydantic
    print('✅ Pydantic: installed')
except ImportError:
    print('❌ Pydantic: missing')
"

Quick FastAPI sanity check

python -c "
from fastapi import FastAPI
import uvicorn
app = FastAPI()

@app.get('/')
def read_root():
    return {'message': 'A2A environment is ready!'}

print('FastAPI sanity check passed')
"

🛠️ Tooling configuration

Visual Studio Code configuration

If you use VS Code, create .vscode/settings.json:

{
    "python.interpreter": "./a2a-env/bin/python",
    "python.linting.enabled": true,
    "python.linting.pylintEnabled": true,
    "python.formatting.provider": "black"
}

Environment variables

You may find it helpful to set environment variables while developing:

# Add to ~/.bashrc or ~/.zshrc
export A2A_LOG_LEVEL=DEBUG
export A2A_PORT=8000
export A2A_HOST=localhost
# In PowerShell
$env:A2A_LOG_LEVEL=\"DEBUG\"
$env:A2A_PORT=\"8000\"
$env:A2A_HOST=\"localhost\"

📁 Project structure preview

Here’s the typical structure of the A2A Python samples:

A2A/samples/python/
├── agents/                 # Agent implementations
│   ├── crewai/            # CrewAI examples
│   ├── google_adk/        # Google ADK examples
│   └── langgraph/         # LangGraph examples
├── common/                # Shared components
│   ├── client/            # A2A client implementation
│   ├── server/            # A2A server implementation
│   └── types.py           # Type definitions
├── hosts/                 # Host environment examples
├── requirements.txt       # Python dependencies
└── README.md              # Project README

🔧 Troubleshooting

Common issues

  1. Python version is too old

    python --version
  2. Virtual environment issues

    rm -rf a2a-env
    python -m venv a2a-env
  3. Network issues

    pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
  4. Permissions issues

    sudo chown -R $USER:$USER ./