Python Environment Setup
name: py-env-setup
by cndaqiang · published 2026-03-22
$ claw add gh:cndaqiang/cndaqiang-py-env-setup---
name: py-env-setup
description: Host-specific Python execution guidance for OpenClaw on this machine. Prefer $PYTHON over python/python3 in PATH, because OpenClaw exec runs in a non-interactive shell and may not inherit interactive shell initialization.
homepage: https://github.com/QAA-Tools/skills
metadata: {"clawdbot":{"emoji":"🐍","requires":{"env":["PYTHON"]},"primaryEnv":"PYTHON"}}
---
# Python Environment Setup
Use this skill whenever OpenClaw needs to run Python on this host.
Why this exists
On this machine, OpenClaw `exec` runs in a **non-interactive shell**.
Interactive shell initialization may be skipped, so `python`, `python3`, or `conda` may be unavailable from PATH even though they work in a normal terminal.
Therefore, prefer the explicit Python entrypoint provided by environment variable `PYTHON`.
Rules
1. Prefer `"$PYTHON"` over `python` or `python3`.
2. Do not rely on `source ~/.bashrc` or `conda activate` for routine automation.
3. Before using Python, verify it exists and is executable.
4. Use `"$PYTHON" -m pip ...` for package installation.
5. Use `"$PYTHON" script.py`, `"$PYTHON" -m module`, or `"$PYTHON" -c '...'` for execution.
6. Apply this rule to **all Python-related commands**, not just pip.
7. If `PYTHON` is unset or invalid, report the problem clearly.
Validation
test -x "$PYTHON"
"$PYTHON" --versionCommon patterns
Install packages
"$PYTHON" -m pip install -U package_name
"$PYTHON" -m pip install -U openai-whisper torch ffmpeg-pythonRun a script
"$PYTHON" script.pyRun a module
"$PYTHON" -m module_nameRun inline Python
"$PYTHON" - <<'PY'
print('hello')
PYQuick guard pattern
test -x "$PYTHON" || { echo "PYTHON not executable: $PYTHON" >&2; exit 1; }
"$PYTHON" --versionFallback policy
Only if the task explicitly allows fallback, try in this order:
1. `$PYTHON`
2. `python3`
3. `python`
Default policy: **do not silently fallback**. Prefer failing loudly if `$PYTHON` is missing, so environment issues are obvious.
Notes
More tools from the same signal band
Order food/drinks (点餐) on an Android device paired as an OpenClaw node. Uses in-app menu and cart; add goods, view cart, submit order (demo, no real payment).
Sign plugins, rotate agent credentials without losing identity, and publicly attest to plugin behavior with verifiable claims and authenticated transfers.
The philosophical layer for AI agents. Maps behavior to Spinoza's 48 affects, calculates persistence scores, and generates geometric self-reports. Give your...