Core Tools
Execute Python Tool
Run Python code in a secure Jupyter notebook environment with rich output support
What it does
The Execute Python tool runs Python code in a secure Jupyter notebook environment. Perfect for data analysis, calculations, visualizations, and any computational tasks your agents need to perform.
Key features
- Execute Python code in isolated Jupyter notebook cells
- Support for popular libraries (pandas, numpy, matplotlib, etc.)
- Rich output formats including text, images, charts, and HTML
- Automatic error handling with detailed tracebacks
- Persistent session state across multiple executions
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
code | string | Yes | The Python code to execute in a single cell |
Common use cases
Data analysis
Analyze datasets and generate statistics.
Create visualizations
Generate charts and graphs for data visualization.
Mathematical calculations
Perform mathematical operations and statistical analysis.
File processing
Process and manipulate various file formats.
Web scraping and APIs
Fetch and process data from web APIs.
Available libraries
Common Python libraries are pre-installed including:
- Data Science: pandas, numpy, scipy, scikit-learn
- Visualization: matplotlib, seaborn, plotly
- Web: requests, beautifulsoup4
- Utilities: json, csv, datetime, os, sys
Output formats
The tool supports rich output including:
- Text: Standard print output and string representations
- Images: PNG, JPEG, SVG graphics from matplotlib, plotly, etc.
- HTML: Rich HTML content and tables
- Charts: Interactive visualizations
- Markdown: Formatted text with markdown syntax
Best practices
- Write clear, well-commented code
- Handle errors gracefully with try/except blocks
- Use print statements to show intermediate results
- Break complex operations into smaller steps
- Import libraries at the beginning of your code
Troubleshooting
“Module not found” errors
- Check if the library is in the available libraries list
- Try importing alternative libraries with similar functionality
- Use built-in Python modules when possible
“Code execution timeout”
- Simplify complex operations
- Avoid infinite loops or very long-running processes
- Break large datasets into smaller chunks
“Memory errors”
- Reduce dataset size or use sampling
- Clear variables you no longer need with
del variable
- Use more memory-efficient data structures
“Syntax errors”
- Check Python syntax carefully
- Ensure proper indentation
- Verify parentheses and brackets are balanced
Related tools
- Postgres SQL - Query databases for data analysis
- Call API - Fetch data from APIs for processing
- Scrape URL - Get web data for analysis