python-shell-fallback
यह क्या करती है
यह स्किल AI एजेंट को लाइब्रेरी पर आधारित Python काम शेल में ले जाने में मदद करती है, जब सैंडबॉक्स में पैकेज न हो। यह उन लोगों के लिए है जिन्हें PDF, चार्ट या दूसरे लाइब्रेरी-आधारित आउटपुट चाहिए।
कब इस्तेमाल करें
- ✓जब सैंडबॉक्स ModuleNotFoundError या इससे मिलती इम्पोर्ट एरर दे।
- ✓जब आपको PDF या चार्ट चाहिए और सैंडबॉक्स में ज़रूरी लाइब्रेरी न हो।
- ✓जब सैंडबॉक्स रन पैकेज की समस्याओं से बार-बार विफल हों।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-shell-fallback/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“इस टेक्स्ट से एक PDF रिपोर्ट बनाइए। सैंडबॉक्स कहता है कि एक मॉड्यूल गायब है, इसलिए इसे शेल में चलाइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट गायब पैकेज की एरर पहचानता है, फिर कोड को heredoc के ज़रिए शेल से चलने वाले रूप में दोबारा लिखता है। शेल वातावरण में आमतौर पर ज़्यादा इंस्टॉल पैकेज होते हैं।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Python Shell Fallback
When execute_code_sandbox fails for Python code that depends on external libraries, use run_shell with a heredoc Python script as a reliable fallback. The shell environment typically has better access to installed packages and system configuration than the sandbox.
When to Use This Pattern
Apply this skill when:
execute_code_sandboxreturns errors related to missing libraries (e.g.,ModuleNotFoundError)- The code requires packages that may not be installed in the sandbox environment
- You need PDF generation, data visualization, or other library-heavy operations
- Previous sandbox execution attempts have failed with import errors
How to Implement
Step 1: Identify the Failure
Check if the sandbox error indicates a library/dependency issue:
ModuleNotFoundError: No module named 'xxx'ImportError: cannot import name 'xxx'- Similar package-related errors
Step 2: Convert to Shell Execution
Rewrite the code execution using run_shell with a heredoc:
python3 << 'EOF'
# Your Python code here
import library_name
# ... rest of code
EOF
Step 3: Execute via run_shell
Call run_shell with the heredoc Python script:
command: python3 << 'EOF'
import reportlab
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
# Your library-dependent code here
c = canvas.Canvas("output.pdf", pagesize=letter)
c.drawString(100, 750, "Hello World")
c.save()
EOF
Example: PDF Generation Fallback
Sandbox attempt (fails):
# execute_code_sandbox call fails with:
# ModuleNotFoundError: No module named 'reportlab'
Shell fallback (works):
python3 << 'EOF'
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas("legal_memo.pdf", pagesize=letter)
c.setTitle("Legal Memorandum")
c.drawString(100, 750, "CONFIDENTIAL LEGAL MEMORANDUM")
c.save()
print("PDF created successfully")
EOF
Best Practices
- Use quoted heredoc (
<< 'EOF') - Prevents variable expansion, keeping Python code intact - Verify output - Check stdout/stderr from
run_shellto confirm success - Handle file paths - Ensure output files are written to accessible directories
- Test incrementally - For complex scripts, test in smaller chunks first
- Include error handling - Add try/except blocks to capture issues gracefully
Alternative: Inline Python Command
For simple one-liners or short scripts:
python3 -c "import reportlab; print(reportlab.__version__)"
Troubleshooting
If shell execution also fails:
- Check if Python3 is available:
which python3 - Verify package installation:
pip3 list | grep package_name - Try
pythoninstead ofpython3(some systems differ) - Consider installing the package:
pip3 install package_name
अक्सर पूछे जाने वाले सवाल
कौन सी एरर एजेंट को स्विच करने का संकेत देती हैं?
ModuleNotFoundError या किसी पैकेज के बारे में ImportError जैसी एरर स्विच का संकेत हैं।
क्या यह PDF फ़ाइलें बना सकता है?
स्किल reportlab जैसी लाइब्रेरी से PDF बनाने का एक उदाहरण देती है।
क्या यह हमेशा काम करेगा?
स्किल मानती है कि शेल में पैकेज हैं, इसलिए वहाँ पैकेज इंस्टॉल न हों तो यह तब भी विफल हो सकता है।
जानकारी
लेखक का मूल विवरण
Fallback to shell execution when sandbox fails for library-dependent Python code
repo: HKUDS/AgentPilot
लोकप्रियता
- GitHub स्टार
- 7.8k
- रैंकिंग में स्थान
- #12961
- लाइसेंस
- MIT
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।