← 返回 Skills 市场
kazuya-ecnu

Auto Conda Env

作者 Kazuya · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ⚠ suspicious
91
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install auto-conda-env
功能描述
自动为Python项目创建或复用匹配的Conda环境,扫描项目依赖文件自动配置运行环境。Auto-create or reuse a Conda env for any Python project — scans deps, matches envs, handles CUDA/GPU needs.
使用说明 (SKILL.md)

Auto Conda Env for Python Project / 自动为Python项目配置Conda环境

触发条件 / When to Use

当用户需要为Python项目配置独立运行环境、自动创建Conda环境,或希望复用已有的匹配环境时,使用本技能。 Use when: setting up an isolated Python env, creating a new Conda env, or reusing an existing one for a project.


执行步骤 / Execution Steps

1. 获取项目路径 / Get Project Path

  • 询问用户提供Python项目文件夹路径,若未指定则默认使用当前工作目录。 Ask for the project folder path; default to current working directory if not provided.
  • 验证路径是否存在且为有效文件夹。 Verify the path exists and is a valid directory.

2. 扫描项目依赖文件 / Scan Dependency Files

进入项目文件夹,按以下优先级扫描:Scan in this order:

优先级 / Priority 文件 / File 提取内容 / What to Extract
1 environment.yml / environment.yaml Python版本 + 所有依赖 / Python version + all deps
2 pyproject.toml project.requires-python + project.dependencies
3 requirements.txt 依赖包列表(检查 .python-version 获取版本)
4 setup.py python_requires + install_requires
5 Pipfile [packages]
6 setup.cfg install_requires
  • 若未找到任何依赖配置文件,默认使用 Python 3.10,无额外依赖。 Default to Python 3.10 with no extra packages if nothing found.

3. 查找 conda 可执行文件 / Find Conda Executable

conda 可能不在 PATH 中,按以下顺序尝试:Try these paths if conda is not in PATH:

which conda
~/.local/bin/conda                                  # pip-installed conda
~/miniconda3/bin/conda                              # standard Miniconda
~/anaconda3/bin/conda                               # standard Anaconda
$HOME/miniconda3/bin/conda
$HOME/anaconda3/bin/conda

保存找到的 conda 路径为 CONDA,后续所有 conda 命令用 CONDA 前缀执行。 Save the working conda path as CONDA; prefix all conda commands with it.

4. 检查现有Conda环境 / Check Existing Environments

  • 执行 CONDA info --envs 获取环境列表。
  • 对每个环境验证:
    1. CONDA run -n \x3Cenv> which python — 确认 python 存在(避免 ghost env)
    2. CONDA run -n \x3Cenv> python --version — 验证 Python 版本
    3. CONDA run -n \x3Cenv> pip list — 验证依赖已安装

⚠️ 部分 conda 环境 python 不在 PATH(如损坏/空环境),conda run 会失败,此时跳过该环境。 Some envs fail conda run — skip them.

若找到完全匹配的环境 → 复用。 若未找到 → 进入步骤 5 创建。

5. 复用或创建环境 / Reuse or Create

复用 / Reuse:

  • 确认环境 python 可执行且版本匹配
  • 验证核心依赖已安装
  • 配置 OpenClaw 后续操作使用此环境

创建新环境 / Create New:

  1. 生成环境名项目文件夹名 → 小写 → 特殊字符替换为 _ → 追加 _env 例 / e.g.:MyProject-2.0myproject_2_0_env

  2. 创建环境

    CONDA create -n \x3Cenv_name> python=\x3Cversion> -y
    
  3. 安装依赖 / Install Dependencies:

    依赖文件 / File 安装命令 / Command
    environment.yml CONDA env update -n \x3Cenv> -f environment.yml --prune
    pyproject.toml CONDA run -n \x3Cenv> pip install .
    requirements.txt CONDA run -n \x3Cenv> pip install -r requirements.txt
    setup.py CONDA run -n \x3Cenv> pip install .
    Pipfile CONDA run -n \x3Cenv> pip install pipenv && CONDA run -n \x3Cenv> pipenv sync
    无配置文件 / None 仅创建空环境 / create empty env only

    💡 pip 安装失败时(如系统保护 PEP 668),追加 --break-system-packages 参数重试。 If pip refuses due to PEP 668, add --break-system-packages.

  4. GPU / CUDA 处理(如需要)/ Handle GPU / CUDA if needed:

    • 检查项目是否 import torch / tensorflow 等
    • 若需要 GPU:CONDA run -n \x3Cenv> pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
    • 验证:CONDA run -n \x3Cenv> python -c "import torch; print(torch.cuda.is_available())"
  5. 验证环境可用 / Verify Env Works:

    CONDA run -n \x3Cenv> python -c "import numpy, scipy, sklearn; print('OK')"
    

    若失败,记录缺失的包并重新安装。

6. 输出结果 / Output Summary

最终告知用户:

环境名称 / Env name: \x3Cname>
Python 版本 / Python: \x3Cversion>
已安装依赖 / Installed: \x3Clist>
环境路径 / Path: /path/to/env
激活命令 / Activate: conda activate \x3Cname>

注意事项 / Notes

  • conda 不在 PATH 是常见问题,优先搜索常见安装路径 Missing conda in PATH is common; search standard install locations first
  • ghost 环境(python 不存在)用 conda run ... which python 排除 Use which python via conda run to detect ghost/broken envs
  • pip 安装失败先尝试加 --break-system-packages Try --break-system-packages when pip is blocked by OS package protection
  • GPU 项目安装 torch 后务必验证 CUDA 可用 Always verify CUDA availability after installing torch
  • 不修改用户现有 conda 安装,只读和复用/创建新环境 Read-only on existing installs; only create/reuse envs, don't modify base

适用场景 / Use Cases

  • 新项目初始化 / New project setup
  • 不同项目需要不同 Python 版本 / Projects needing different Python versions
  • 有 CUDA 依赖的 ML/DL 项目 / ML/DL projects with CUDA dependencies
  • 依赖冲突隔离 / Isolating dependency conflicts
  • 团队环境标准化 / Team environment standardization
安全使用建议
This skill appears to do what it claims, but take precautions before running it: (1) fix the metadata: conda should be declared as a required binary so the agent fails early if conda is absent; (2) do not blindly accept the recommendation to use --break-system-packages — understand the implications and only use it with explicit user consent; (3) review the project's dependency files yourself before allowing the skill to run pip/conda install (malicious packages can execute code at install time); (4) run the skill in a safe context (non-production machine or container) the first time to confirm behavior; (5) ensure the provided project path is correct to avoid unintended filesystem changes. If you need higher assurance, require explicit confirmations in SKILL.md before any network installs or system-modifying commands.
功能分析
Type: OpenClaw Skill Name: auto-conda-env Version: 1.1.0 The skill bundle is a utility designed to automate the creation and management of Conda environments for Python projects. The logic resides in SKILL.md, which instructs the AI agent to scan for dependency files (like requirements.txt or environment.yml), locate the conda executable, and execute standard environment setup commands. While the skill performs high-risk actions such as shell command execution and package installation, these behaviors are strictly aligned with its stated purpose and lack any indicators of malicious intent, data exfiltration, or persistence.
能力评估
Purpose & Capability
The SKILL.md behavior (search for and run conda, create/inspect conda envs, run pip installs) matches the described purpose. However, the declared required binaries list includes python3 and pip but does NOT declare conda even though the instructions depend heavily on conda. This is an inconsistency that could lead to unexpected failures or hidden assumptions about available tooling.
Instruction Scope
Instructions explicitly run conda commands, run pip installs (including installing pipenv), probe common home paths for conda, and suggest adding the --break-system-packages flag if pip is blocked. Recommending --break-system-packages is risky because it bypasses OS package protections and can alter system package state; running arbitrary pip installs from project files will fetch code from the network and execute package install scripts. The skill does not instruct exfiltration or contact unknown endpoints, but it grants broad discretion to run commands that change system state and install remote code.
Install Mechanism
No install spec — instruction-only with a tiny helper script. Nothing is written to disk by a packaged installer. This is the lower-risk pattern for a skill that delegates runtime behavior to the agent.
Credentials
The skill requests no credentials or environment variables, which is appropriate. It does, however, omit declaring the conda binary as required even though SKILL.md assumes its presence; that mismatch should be addressed. The network activity (pip installs, optional PyTorch wheel index URL) is expected for environment setup and does not require secrets, but you should be comfortable with arbitrary package installs coming from public registries.
Persistence & Privilege
always is false, no privileged or persistent installation is requested, and the skill does not attempt to modify other skills or system-wide agent settings. It only instructs creating/using conda envs in user space.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install auto-conda-env
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /auto-conda-env 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
新增:conda路径自动搜索(处理PATH缺失)、ghost环境检测、PEP 668保护处理、GPU/CUDA支持、安装验证步骤。中英双语。Added: auto conda path search, ghost env detection, PEP 668 handling, GPU/CUDA support, env verification.
元数据
Slug auto-conda-env
版本 1.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Auto Conda Env 是什么?

自动为Python项目创建或复用匹配的Conda环境,扫描项目依赖文件自动配置运行环境。Auto-create or reuse a Conda env for any Python project — scans deps, matches envs, handles CUDA/GPU needs. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 91 次。

如何安装 Auto Conda Env?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install auto-conda-env」即可一键安装,无需额外配置。

Auto Conda Env 是免费的吗?

是的,Auto Conda Env 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Auto Conda Env 支持哪些平台?

Auto Conda Env 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Auto Conda Env?

由 Kazuya(@kazuya-ecnu)开发并维护,当前版本 v1.1.0。

💬 留言讨论