Fallback to run_shell with embedded Python when execute_code_sandbox fails due to e2b unavailability
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-sandbox-fallback-python-2937adf271e0 ,按照其中的说明把「sandbox-fallback-python」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Apply this skill when execute_code_sandbox fails with errors indicating:
This fallback allows you to execute Python code directly via shell, bypassing the sandbox infrastructure.
Identify fallback necessity from error messages like:
Instead of execute_code_sandbox, use run_shell with a Python heredoc or inline script:
python3 << 'EOF'
# Your Python code here
print("Hello from fallback execution")
EOF
If your Python code requires packages not guaranteed to be installed:
pip install package_name package_name2 && python3 << 'EOF'
# Your Python code here
import package_name
print("Code with dependencies executed")
EOF
For scripts that need to read/write files:
ls to verify file operationspython3 << 'EOF'
import os
# Write output to file
with open("output.txt", "w") as f:
f.write("Results here")
# Verify
print(f"Working directory: {os.getcwd()}")
EOF
python3 << 'EOF'
result = sum(range(100))
print(f"Sum: {result}")
EOF
pip install requests -q && python3 << 'EOF'
import requests
response = requests.get("https://api.example.com/data")
print(response.json())
EOF
python3 << 'EOF'
import json
data = {"key": "value", "count": 42}
output = json.dumps(data, indent=2)
print(output)
# Save to file
with open("data.json", "w") as f:
f.write(output)
EOF
<< 'EOF' prevents variable expansion issuespip install -q to reduce output noise