PythonEnvironment
autogen.environments.python_environment.PythonEnvironment #
Bases: ABC
Python execution environments base class
Initialize the Python environment.
Source code in autogen/environments/python_environment.py
get_executable abstractmethod
#
Get the path to the Python executable in this environment.
RETURNS | DESCRIPTION |
---|---|
str | The full path to the Python executable. |
execute_code abstractmethod
async
#
Execute the given code in this environment.
PARAMETER | DESCRIPTION |
---|---|
code | The Python code to execute. TYPE: |
script_path | Path where the code should be saved before execution. TYPE: |
timeout | Maximum execution time in seconds. TYPE: |
RETURNS | DESCRIPTION |
---|---|
dict[str, Any] | dict with execution results including stdout, stderr, and success status. |
Source code in autogen/environments/python_environment.py
get_current_python_environment classmethod
#
Get the current Python environment or the specified one if provided.
PARAMETER | DESCRIPTION |
---|---|
python_environment | Optional environment to return if specified. TYPE: |
RETURNS | DESCRIPTION |
---|---|
Optional[PythonEnvironment] | The current Python environment or None if none is active. |