360 Secure SkillHub
360 安全技能中心

Python Support

该 Skill 面向 OpenClaw 代理的 Python 使用场景,给出环境检查命令、pip 依赖安装与运行时自动安装写法、脚本执行建议,以及 shebang、错误处理、编码和路径等最佳实践,并引用风格指南等参考文档;描述中提到的测试与调试参考文件在文件列表中缺失。

分类:开发
terrycarter1985
terrycarter1985
热度 41.77
最近更新 2026-05-11 17:44:29

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add terrycarter1985/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