> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phidata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PythonAgent

## Example

```python python_agent.py theme={null}
from phi.agent.python import PythonAgent
from phi.file.local.csv import CsvFile

python_agent = PythonAgent(
    files=[
        CsvFile(
            path="https://phidata-public.s3.amazonaws.com/demo_data/IMDB-Movie-Data.csv",
            description="Contains information about movies from IMDB.",
        )
    ],
    pip_install=True,
    show_function_calls=True,
)

python_agent.print_response("What is the average rating of movies?")
```

## PythonAgent Params

| Parameter | Type | Default | Description |
| - | - | - | - |
| `name` | `str` | `"PythonAgent"` | Name of the PythonAgent. |
| `files` | `List[File]` | `None` | List of Files available for the PythonAgent. |
| `file_information` | `str` | `None` | Provide information about Files as a string. |
| `charting_libraries` | `List[str]` | `['plotly', 'matplotlib', 'seaborn']` | List of charting libraries the PythonAgent can use. |
| `followups` | `bool` | `False` | If the PythonAgent is allowed to ask follow-up questions. |
| `read_tool_call_history` | `bool` | `True` | If the DuckDbAgent is allowed to read the tool call history. |
| `base_dir` | `Path` | `.` | Where to save files if needed. |
| `save_and_run` | `bool` | `True` | If the PythonAgent is allowed to save and run python code. |
| `pip_install` | `bool` | `False` | If the PythonAgent is allowed to `pip install` libraries. Disabled by default for security reasons. |
| `run_code` | `bool` | `False` | If the PythonAgent is allowed to run python code directly. Disabled by default for security reasons. |
| `list_files` | `bool` | `False` | If the PythonAgent is allowed to list files. |
| `run_files` | `bool` | `True` | If the PythonAgent is allowed to run files. |
| `read_files` | `bool` | `False` | If the PythonAgent is allowed to read files. |
| `safe_globals` | `dict` | `None` | Provide a list of global variables to for the PythonAgent. |
| `safe_locals` | `dict` | `None` | Provide a list of local variables to for the PythonAgent. |
| `add_chat_history_to_messages` | `bool` | `True` | If the chat history should be added to the messages. |
| `num_history_messages` | `int` | `6` | Number of history messages to add to the response. |

## Agent Reference

`PythonAgent` is a subclass of the `Agent` class and has access to the same params

<Snippet file="agent-reference.mdx" />


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.