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.)
- Enhanced output display with separate sections for different output types
- Smart output categorization - stdout, stderr, results, and text outputs are displayed distinctly
- 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 |
Output types & display
The tool now intelligently categorizes and displays different types of output:📤 Output (stdout)
Print statements and console output appear in a clean gray section:📊 Result (expression results)
The final expression result is highlighted in a blue section:⚠️ Warnings/Errors (stderr)
Non-fatal warnings and errors appear in an orange warning section:🎨 Rich Media (charts, images, etc.)
Visual outputs like charts and images are displayed with full formatting:Common use cases
Data analysis with clear output
Create visualizations with status updates
Mathematical calculations with explanations
Error handling demonstration
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
Visual improvements
✨ New in latest version:- Color-coded output sections for easy identification
- Collapsible code view to focus on results
- Success indicators for code that runs without visible output
- Enhanced error display with structured error information
- Rich media rendering for charts, images, and formatted data
Best practices
- Use
print()
statements to show progress and intermediate results - Structure your code with clear steps and explanations
- Handle errors gracefully with try/except blocks
- Break complex operations into smaller, trackable 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
- Simplify complex operations
- Avoid infinite loops or very long-running processes
- Break large datasets into smaller chunks
- Reduce dataset size or use sampling
- Clear variables you no longer need with
del variable
- Use more memory-efficient data structures
- Use
print()
statements to generate stdout output - Ensure your final line is an expression (not assignment) to see results
- Check that your code doesn’t have syntax errors
Related tools
- Postgres SQL - Query databases for data analysis
- Call API - Fetch data from APIs for processing
- Scrape URL - Get web data for analysis