with one click
python-shell-workaround
Workaround for executing Python code with external packages when sandbox fails
Menu
Workaround for executing Python code with external packages when sandbox fails
| name | python-shell-workaround |
| description | Workaround for executing Python code with external packages when sandbox fails |
Use 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')
EOF
Use 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')
EOF
python3 -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.pyDelegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.
Incremental audio production with duration mismatch handling, adaptive stem extension, and pre-mix alignment verification
Audio production with diagnostic analysis, timecode parsing from documents, and verified export workflow
Incremental audio production with duration alignment handling, per-stem verification, and adaptive extension strategies
Step-by-step audio production with per-stem verification, timing alignment, and incremental quality gates
End-to-end audio production workflow with stems, effects, archiving, and verification