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.
- venv
- Conda
- Poetry
Create and activate:
python3 -m venv autogen
source autogen/bin/activate
To deactivate later, run:
deactivate
Install Conda if you have not already.
Create and activate:
conda create -n autogen python=3.10
conda activate autogen
To deactivate later, run:
conda deactivate
Install Poetry if you have not already.
Create and activate:
poetry init
poetry shell
poetry add autogen
To deactivate later, run:
exit
Install AutoGen
AutoGen requires Python version >= 3.8, < 3.13. It can be installed from pip:
pip install autogen
openai>=1
is required.
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.