python-shell-workaround
하는 일
이 스킬은 openpyxl, python-docx, pandas 같은 패키지를 쓰는 Python 코드의 우회 방법입니다. 샌드박스에 그 패키지가 없는 사람에게 맞습니다.
사용하는 경우
- ✓샌드박스에서 openpyxl이나 pandas 같은 패키지를 가져오는 코드가 실패할 때.
- ✓패키지를 테스트하려고 한 줄짜리 빠른 Python 명령이 필요할 때.
- ✓샌드박스 대신 셸에서 긴 Python 작업을 실행해야 하는 경우.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-shell-workaround/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“openpyxl로 헤더 행이 있는 Excel 파일을 만들어 주세요. 샌드박스가 실패했으니 다른 방법으로 실행해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 Python 코드를 한 줄 셸 명령이나 heredoc으로 바꾸고, 셸 도구로 실행합니다. 그다음 출력을 확인해 파일이 만들어졌는지 확인합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Python Shell Workaround
When to Use This Skill
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.
The Pattern
Instead of relying solely on execute_code_sandbox, use run_shell with inline Python commands as a fallback:
python3 -c "your python code here"
Step-by-Step Instructions
Step 1: Detect Sandbox Failure
Watch for errors like:
- ModuleNotFoundError for common packages
- Import errors for external libraries
- Sandbox environment limitations
Step 2: Convert Python Code to Shell Command
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
Step 3: Execute with run_shell
Use run_shell to execute the command:
tool: run_shell
command: python3 -c "import openpyxl; print('Package available')"
Step 4: Verify Output
Check the stdout/stderr from run_shell to confirm success, then proceed with subsequent steps.
Best Practices
- Escape quotes properly: Use single quotes inside double-quoted strings or vice versa
- Use heredocs for multiline code: Cleaner and easier to debug
- Install packages if needed: Add
pip install packagebefore your Python command if packages are missing - Chain commands safely: Use
&&to ensure prerequisites succeed before running Python code
Example Scenarios
Creating Excel Files
python3 << '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
Creating Word Documents
python3 -c "
from docx import Document
doc = Document()
doc.add_heading('Report', 0)
doc.save('report.docx')
print('Document created')
"
Limitations
- Complex multiline scripts are harder to maintain as one-liners
- Debugging is less convenient than in sandbox
- Some packages may still not be available in the shell environment
Related Patterns
- If packages are truly unavailable, consider installing them first:
pip install package_name && python3 -c "..." - For persistent scripts, write to a
.pyfile first, then execute withpython3 script.py
자주 묻는 질문
한 줄 명령과 heredoc은 언제 각각 쓰나요?
짧은 코드에는 한 줄 명령이, 여러 단계가 있는 긴 스크립트에는 heredoc이 맞습니다.
에이전트는 어떻게 작동했다는 것을 아나요?
출력된 결과를 확인한 뒤 파일이 있는지 확인합니다.
스킬은 어떤 패키지를 언급하나요?
샌드박스에 없을 수 있는 패키지의 예로 openpyxl, python-docx, pandas를 언급합니다.
상세 정보
작성자의 원본 설명
Workaround for executing Python code with external packages when sandbox fails
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12962
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.