Skip to main content

Installation

Create a virtual environment (optional)

When installing AutoGen locally, we recommend using a virtual environment for the installation. This will ensure that the dependencies for AutoGen are isolated from the rest of your system.

Create and activate:

python3 -m venv .venv
source .venv/bin/activate

To deactivate later, run:

deactivate

Install AutoGen

AutoGen requires Python version >= 3.8, < 3.13. It can be installed from pip:

pip install autogen-agentchat~=0.2

Install Docker for Code Execution

We recommend using Docker for code execution. To install Docker, follow the instructions for your operating system on the Docker website.

A simple example of how to use Docker for code execution is shown below:

from pathlib import Path
from autogen import UserProxyAgent
from autogen.coding import DockerCommandLineCodeExecutor

work_dir = Path("coding")
work_dir.mkdir(exist_ok=True)

with DockerCommandLineCodeExecutor(work_dir=work_dir) as code_executor:
user_proxy = UserProxyAgent(
name="user_proxy",
code_execution_config={"executor": code_executor},
)

To learn more about code executors, see the code executors tutorial.

You might have seen a different way of defining the executors without creating the executor object, please refer to FAQ for this legacy code executor.