关于 python-executor
python-executor 是通过 inference.sh CLI 运行 Python 代码的技能,面向需要执行脚本的 Agent。它在隔离的 CPU 环境中提供多类预装库,并可返回保存到 outputs/ 的文件。
主要功能
- 01隔离环境中执行 Python 代码
- 02预装网页、数据及媒体处理库
- 03设置超时和工作目录
- 04自动返回 outputs/ 中的文件
- 05提供 8GB 和 16GB 内存版本
适用场景
- 01抓取网页并提取内容
- 02分析数据并生成图表
- 03处理图像、视频或 3D 模型
- 04调用外部 API 或生成 PDF
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ qu-skills/ superpowers --skill python-executor安装后在 Claude Code 中输入/python-executor确认已加载。
详细介绍
安装 belt CLI 技能:
npx skills add belt-sh/cli
Python 代码执行器
在安全的沙盒环境中执行 Python 代码,预装 100 多个库。

快速开始
需要 inference.sh CLI(
belt)。安装说明
belt login
# Run Python code
belt app run infsh/python-executor --input '{
"code": "import pandas as pd\nprint(pd.__version__)"
}'
应用详情
| 属性 | 值 |
|---|---|
| 应用 ID | infsh/python-executor |
| 环境 | Python 3.10,仅 CPU |
| RAM | 8GB(默认)/ 16GB(high_memory) |
| 超时 | 1-300 秒(默认:30) |
输入架构
{
"code": "print('Hello World!')",
"timeout": 30,
"capture_output": true,
"working_dir": null
}
预装库
网页抓取与 HTTP
requests、httpx、aiohttp- HTTP 客户端beautifulsoup4、lxml- HTML/XML 解析selenium、playwright- 浏览器自动化scrapy- 网页抓取框架
数据处理
numpy、pandas、scipy- 数值计算matplotlib、seaborn、plotly- 可视化
图像处理
pillow、opencv-python-headless- 图像操作scikit-image、imageio- 图像算法
视频与音频
moviepy- 视频编辑av(PyAV)、ffmpeg-python- 视频处理pydub- 音频操作
3D 处理
trimesh、open3d- 3D 网格处理numpy-stl、meshio、pyvista- 3D 文件格式
文档与图形
svgwrite、cairosvg- SVG 创建reportlab、pypdf2- PDF 生成
示例
网页抓取
belt 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)"
}'
使用可视化进行数据分析
belt 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!\")"
}'
图像处理
belt 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!\")"
}'
视频创建
belt 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 模型处理
belt 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 调用
belt 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))"
}'
文件输出
保存到 outputs/ 的文件会自动返回:
# 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')
变体
# Default (8GB RAM)
belt app run infsh/python-executor --input input.json
# High memory (16GB RAM) for large datasets
belt app run infsh/python-executor@high_memory --input input.json
使用场景
- 网页抓取 - 从网站提取数据
- 数据分析 - 处理并可视化数据集
- 图像处理 - 调整图像大小、裁剪和合成图像
- 视频创建 - 生成带文字叠加的视频
- 3D 处理 - 加载、转换并导出 3D 模型
- API 集成 - 调用外部 API
- PDF 生成 - 创建报告和文档
- 自动化 - 运行任意 Python 脚本
重要说明
- 仅 CPU - 不含 GPU/ML 库(此类任务请使用专用 AI 应用)
- 安全执行 - 在隔离的子进程中运行
- 非交互式 - 使用
plt.savefig(),而非plt.show() - 文件检测 - 自动检测并返回输出文件
相关技能
# AI image generation (for ML-based images)
npx skills add inference-sh/skills@ai-image-generation
# AI video generation (for ML-based videos)
npx skills add inference-sh/skills@ai-video-generation
# LLM models (for text generation)
npx skills add inference-sh/skills@llm-models
文档
评论
支持 Markdown