You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Installation.mdx 2.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import Tabs from '@theme/Tabs';
  2. import TabItem from '@theme/TabItem';
  3. # Installation
  4. ## Create a virtual environment (optional)
  5. 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.
  6. <Tabs>
  7. <TabItem value="venv" label="venv" default>
  8. Create and activate:
  9. ```bash
  10. python3 -m venv pyautogen
  11. source pyautogen/bin/activate
  12. ```
  13. To deactivate later, run:
  14. ```bash
  15. deactivate
  16. ```
  17. </TabItem>
  18. <TabItem value="conda" label="Conda">
  19. [Install Conda](https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html) if you have not already.
  20. Create and activate:
  21. ```bash
  22. conda create -n pyautogen python=3.10
  23. conda activate pyautogen
  24. ```
  25. To deactivate later, run:
  26. ```bash
  27. conda deactivate
  28. ```
  29. </TabItem>
  30. <TabItem value="poetry" label="Poetry">
  31. [Install Poetry](https://python-poetry.org/docs/#installation) if you have not already.
  32. Create and activate:
  33. ```bash
  34. poetry init
  35. poetry shell
  36. poetry add pyautogen
  37. ```
  38. To deactivate later, run:
  39. ```bash
  40. exit
  41. ```
  42. </TabItem>
  43. </Tabs>
  44. ## Install AutoGen
  45. AutoGen requires **Python version >= 3.8, < 3.13**. It can be installed from pip:
  46. ```bash
  47. pip install pyautogen
  48. ```
  49. :::info
  50. `pyautogen<0.2` required `openai<1`. Starting from pyautogen v0.2, `openai>=1` is required.
  51. :::
  52. ## Install Docker for Code Execution
  53. We recommend using Docker for code execution.
  54. To install Docker, follow the instructions for your operating system on the [Docker website](https://docs.docker.com/get-docker/).
  55. A simple example of how to use Docker for code execution is shown below:
  56. ```python
  57. from pathlib import Path
  58. from autogen import UserProxyAgent
  59. from autogen.coding import DockerCommandLineCodeExecutor
  60. work_dir = Path("coding")
  61. work_dir.mkdir(exist_ok=True)
  62. with DockerCommandLineCodeExecutor(work_dir=work_dir) as code_executor:
  63. user_proxy = UserProxyAgent(
  64. name="user_proxy",
  65. code_execution_config={"executor": code_executor},
  66. )
  67. ```
  68. To learn more about code executors, see the [code executors tutorial](/docs/tutorial/code-executors).
  69. You might have seen a different way of defining the executors without creating the
  70. executor object, please refer to FAQ for this [legacy code executor](/docs/FAQ#legacy-code-executor).