Workaround for executing Python code with external packages when sandbox fails
63
73%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./benchmarks/gdpval/skills/python-shell-workaround/SKILL.mdUse this pattern when execute_code_sandbox fails with Python code that requires external packages (like openpyxl, python-docx, pandas, etc.) that may not be available in the sandbox environment.
Instead of relying solely on execute_code_sandbox, use run_shell with inline Python commands as a fallback:
python3 -c "your python code here"Watch for errors like:
Transform your Python script into a one-liner or use a heredoc for longer scripts:
For simple code:
python3 -c "import openpyxl; wb = openpyxl.Workbook(); wb.save('file.xlsx')"For complex code (using heredoc):
python3 << 'EOF'
import openpyxl
from openpyxl.utils import get_column_letter
wb = openpyxl.Workbook()
ws = wb.active
ws['A1'] = 'Header'
wb.save('output.xlsx')
print('File created successfully')
EOFUse run_shell to execute the command:
tool: run_shell
command: python3 -c "import openpyxl; print('Package available')"Check the stdout/stderr from run_shell to confirm success, then proceed with subsequent steps.
pip install package before your Python command if packages are missing&& to ensure prerequisites succeed before running Python codepython3 << 'EOF'
import openpyxl
from openpyxl.worksheet.datavalidation import DataValidation
wb = openpyxl.Workbook()
ws = wb.active
ws.title = "Data"
# Add headers
headers = ['Name', 'Email', 'Status']
for col, header in enumerate(headers, 1):
ws.cell(row=1, column=col, value=header)
wb.save('output.xlsx')
EOFpython3 -c "
from docx import Document
doc = Document()
doc.add_heading('Report', 0)
doc.save('report.docx')
print('Document created')
"pip install package_name && python3 -c "...".py file first, then execute with python3 script.pyc5a9c4b
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.