python-executor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePython Code Executor
Python代码执行器

Execute Python code in a safe, sandboxed environment with 100+ pre-installed libraries.

在预装了100+个库的安全沙箱环境中执行Python代码。
Quick Start
快速开始
bash
curl -fsSL https://cli.inference.sh | sh && infsh loginbash
curl -fsSL https://cli.inference.sh | sh && infsh loginRun Python code
Run Python code
infsh app run infsh/python-executor --input '{
"code": "import pandas as pd\nprint(pd.version)"
}'
undefinedinfsh app run infsh/python-executor --input '{
"code": "import pandas as pd\nprint(pd.version)"
}'
undefinedApp Details
应用详情
| Property | Value |
|---|---|
| App ID | |
| Environment | Python 3.10, CPU-only |
| RAM | 8GB (default) / 16GB (high_memory) |
| Timeout | 1-300 seconds (default: 30) |
| 属性 | 值 |
|---|---|
| 应用ID | |
| 运行环境 | Python 3.10,仅CPU |
| 内存 | 8GB(默认)/ 16GB(high_memory) |
| 超时时间 | 1-300秒(默认:30) |
Input Schema
输入Schema
json
{
"code": "print('Hello World!')",
"timeout": 30,
"capture_output": true,
"working_dir": null
}json
{
"code": "print('Hello World!')",
"timeout": 30,
"capture_output": true,
"working_dir": null
}Pre-installed Libraries
预装库
Web Scraping & HTTP
网页爬取与HTTP
- ,
requests,httpx- HTTP clientsaiohttp - ,
beautifulsoup4- HTML/XML parsinglxml - ,
selenium- Browser automationplaywright - - Web scraping framework
scrapy
- ,
requests,httpx- HTTP客户端aiohttp - ,
beautifulsoup4- HTML/XML解析lxml - ,
selenium- 浏览器自动化playwright - - 网页爬取框架
scrapy
Data Processing
数据处理
- ,
numpy,pandas- Numerical computingscipy - ,
matplotlib,seaborn- Visualizationplotly
- ,
numpy,pandas- 数值计算scipy - ,
matplotlib,seaborn- 数据可视化plotly
Image Processing
图像处理
- ,
pillow- Image manipulationopencv-python-headless - ,
scikit-image- Image algorithmsimageio
- ,
pillow- 图像操作opencv-python-headless - ,
scikit-image- 图像算法imageio
Video & Audio
视频与音频
- - Video editing
moviepy - (PyAV),
av- Video processingffmpeg-python - - Audio manipulation
pydub
- - 视频编辑
moviepy - (PyAV),
av- 视频处理ffmpeg-python - - 音频操作
pydub
3D Processing
3D处理
- ,
trimesh- 3D mesh processingopen3d - ,
numpy-stl,meshio- 3D file formatspyvista
- ,
trimesh- 3D网格处理open3d - ,
numpy-stl,meshio- 3D文件格式pyvista
Documents & Graphics
文档与图形
- ,
svgwrite- SVG creationcairosvg - ,
reportlab- PDF generationpypdf2
- ,
svgwrite- SVG创建cairosvg - ,
reportlab- PDF生成pypdf2
Examples
示例
Web Scraping
网页爬取
bash
infsh app run infsh/python-executor --input '{
"code": "import requests\nfrom bs4 import BeautifulSoup\n\nresponse = requests.get(\"https://example.com\")\nsoup = BeautifulSoup(response.content, \"html.parser\")\nprint(soup.find(\"title\").text)"
}'bash
infsh app run infsh/python-executor --input '{
"code": "import requests\nfrom bs4 import BeautifulSoup\n\nresponse = requests.get(\"https://example.com\")\nsoup = BeautifulSoup(response.content, \"html.parser\")\nprint(soup.find(\"title\").text)"
}'Data Analysis with Visualization
带可视化的数据分析
bash
infsh app run infsh/python-executor --input '{
"code": "import pandas as pd\nimport matplotlib.pyplot as plt\n\ndata = {\"name\": [\"Alice\", \"Bob\"], \"sales\": [100, 150]}\ndf = pd.DataFrame(data)\n\nplt.bar(df[\"name\"], df[\"sales\"])\nplt.savefig(\"outputs/chart.png\")\nprint(\"Chart saved!\")"
}'bash
infsh app run infsh/python-executor --input '{
"code": "import pandas as pd\nimport matplotlib.pyplot as plt\n\ndata = {\"name\": [\"Alice\", \"Bob\"], \"sales\": [100, 150]}\ndf = pd.DataFrame(data)\n\nplt.bar(df[\"name\"], df[\"sales\"])\nplt.savefig(\"outputs/chart.png\")\nprint(\"Chart saved!\")"
}'Image Processing
图像处理
bash
infsh app run infsh/python-executor --input '{
"code": "from PIL import Image\nimport numpy as np\n\n# Create gradient image\narr = np.linspace(0, 255, 256*256, dtype=np.uint8).reshape(256, 256)\nimg = Image.fromarray(arr, mode=\"L\")\nimg.save(\"outputs/gradient.png\")\nprint(\"Image created!\")"
}'bash
infsh app run infsh/python-executor --input '{
"code": "from PIL import Image\nimport numpy as np\n\n# Create gradient image\narr = np.linspace(0, 255, 256*256, dtype=np.uint8).reshape(256, 256)\nimg = Image.fromarray(arr, mode=\"L\")\nimg.save(\"outputs/gradient.png\")\nprint(\"Image created!\")"
}'Video Creation
视频制作
bash
infsh app run infsh/python-executor --input '{
"code": "from moviepy.editor import ColorClip, TextClip, CompositeVideoClip\n\nclip = ColorClip(size=(640, 480), color=(0, 100, 200), duration=3)\ntxt = TextClip(\"Hello!\", fontsize=70, color=\"white\").set_position(\"center\").set_duration(3)\nvideo = CompositeVideoClip([clip, txt])\nvideo.write_videofile(\"outputs/hello.mp4\", fps=24)\nprint(\"Video created!\")",
"timeout": 120
}'bash
infsh app run infsh/python-executor --input '{
"code": "from moviepy.editor import ColorClip, TextClip, CompositeVideoClip\n\nclip = ColorClip(size=(640, 480), color=(0, 100, 200), duration=3)\ntxt = TextClip(\"Hello!\", fontsize=70, color=\"white\").set_position(\"center\").set_duration(3)\nvideo = CompositeVideoClip([clip, txt])\nvideo.write_videofile(\"outputs/hello.mp4\", fps=24)\nprint(\"Video created!\")",
"timeout": 120
}'3D Model Processing
3D模型处理
bash
infsh app run infsh/python-executor --input '{
"code": "import trimesh\n\nsphere = trimesh.creation.icosphere(subdivisions=3, radius=1.0)\nsphere.export(\"outputs/sphere.stl\")\nprint(f\"Created sphere with {len(sphere.vertices)} vertices\")"
}'bash
infsh app run infsh/python-executor --input '{
"code": "import trimesh\n\nsphere = trimesh.creation.icosphere(subdivisions=3, radius=1.0)\nsphere.export(\"outputs/sphere.stl\")\nprint(f\"Created sphere with {len(sphere.vertices)} vertices\")"
}'API Calls
API调用
bash
infsh app run infsh/python-executor --input '{
"code": "import requests\nimport json\n\nresponse = requests.get(\"https://api.github.com/users/octocat\")\ndata = response.json()\nprint(json.dumps(data, indent=2))"
}'bash
infsh app run infsh/python-executor --input '{
"code": "import requests\nimport json\n\nresponse = requests.get(\"https://api.github.com/users/octocat\")\ndata = response.json()\nprint(json.dumps(data, indent=2))"
}'File Output
文件输出
Files saved to are automatically returned:
outputs/python
undefined保存到目录的文件会自动返回:
outputs/python
undefinedThese files will be in the response
These files will be in the response
plt.savefig('outputs/chart.png')
df.to_csv('outputs/data.csv')
video.write_videofile('outputs/video.mp4')
mesh.export('outputs/model.stl')
undefinedplt.savefig('outputs/chart.png')
df.to_csv('outputs/data.csv')
video.write_videofile('outputs/video.mp4')
mesh.export('outputs/model.stl')
undefinedVariants
变体
bash
undefinedbash
undefinedDefault (8GB RAM)
Default (8GB RAM)
infsh app run infsh/python-executor --input input.json
infsh app run infsh/python-executor --input input.json
High memory (16GB RAM) for large datasets
High memory (16GB RAM) for large datasets
infsh app run infsh/python-executor@high_memory --input input.json
undefinedinfsh app run infsh/python-executor@high_memory --input input.json
undefinedUse Cases
适用场景
- Web scraping - Extract data from websites
- Data analysis - Process and visualize datasets
- Image manipulation - Resize, crop, composite images
- Video creation - Generate videos with text overlays
- 3D processing - Load, transform, export 3D models
- API integration - Call external APIs
- PDF generation - Create reports and documents
- Automation - Run any Python script
- 网页爬取 - 从网站提取数据
- 数据分析 - 处理并可视化数据集
- 图像操作 - 调整大小、裁剪、合成图像
- 视频制作 - 生成带文本叠加层的视频
- 3D处理 - 加载、转换、导出3D模型
- API集成 - 调用外部API
- PDF生成 - 创建报告和文档
- 自动化 - 运行任意Python脚本
Important Notes
重要说明
- CPU-only - No GPU/ML libraries (use dedicated AI apps for that)
- Safe execution - Runs in isolated subprocess
- Non-interactive - Use not
plt.savefig()plt.show() - File detection - Output files are auto-detected and returned
- 仅支持CPU - 无GPU/ML库(此类需求请使用专用AI应用)
- 安全执行 - 在独立子进程中运行
- 非交互式 - 使用而非
plt.savefig()plt.show() - 文件检测 - 输出文件会被自动检测并返回
Related Skills
相关技能
bash
undefinedbash
undefinedAI image generation (for ML-based images)
AI image generation (for ML-based images)
npx skills add inferencesh/skills@ai-image-generation
npx skills add inferencesh/skills@ai-image-generation
AI video generation (for ML-based videos)
AI video generation (for ML-based videos)
npx skills add inferencesh/skills@ai-video-generation
npx skills add inferencesh/skills@ai-video-generation
LLM models (for text generation)
LLM models (for text generation)
npx skills add inferencesh/skills@llm-models
undefinednpx skills add inferencesh/skills@llm-models
undefinedDocumentation
文档
- Running Apps - How to run apps via CLI
- App Code - Understanding app execution
- Sandboxed Code Execution - Safe code execution for agents