360 Secure SkillHub
360 安全技能中心

Python Support

该技能为OpenClaw提供全方位Python支持,核心功能含环境检查、脚本运行、依赖安全管理、代码质量保障及最佳实践指导。典型场景包括运行Python脚本、管理虚拟环境、安装依赖包、调试代码、规范代码格式,输入为命令行指令或Python代码片段,输出环境信息、执行结果等。

terrycarter1985
terrycarter1985
热度 57.39
最近更新 2026-05-11 17:44:29
分类:开发依赖:代码执行 / 读写文件应用场景:代码生成 / 调试排错 / 自动化脚本 / DevOps

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add python-support
Metadata
name
python-support
description
Python language support for OpenClaw agents. Provides environment setup, dependency management, linting, testing, and best practices for Python code execution. Use when running Python scripts, managing virtual environments, installing packages, debugging Python code, or ensuring code quality with linting and formatting.

Python Support

Quick Start

Use this skill for all Python-related operations in OpenClaw.

Environment Check

Verify Python environment:

python3 --version
pip3 --list
which python3

Running Scripts

Always use absolute paths and specify Python interpreter explicitly:

python3 /path/to/script.py

Dependency Management

Install packages safely:

pip3 install --quiet package-name

For one-off scripts requiring dependencies, use inline installation with verification:

import subprocess
import sys

def ensure_package(package):
    try:
        __import__(package)
    except ImportError:
        subprocess.check_call([sys.executable, "-m", "pip", "install", "--quiet", package])

Best Practices

  1. Shebang: Use #!/usr/bin/env python3 for executable scripts
  2. Error handling: Always include try/except blocks for external operations
  3. Encoding: Specify encoding="utf-8" for all file operations
  4. Paths: Use pathlib.Path for cross-platform path handling
  5. Output: Prefer JSON or machine-readable formats for structured output

References