Skip to main content

Enhanced CLI on top of conda: backup, migrate, clone, pack, batch clean, friendly errors.

Project description

conda-helper

Make Conda environment operations beautiful, safe, and repeatable.
让 Conda 环境管理更优雅、更安全、更可复现。

English · 中文 · Website · Commands · Development

Python Platform License CLI Website


Backup Restore Clone Pack Clean Doctor Panel
Versioned YAML Name override One command Offline archive Batch + cache Friendly hints Interactive UI

English

conda-helper is a small, cross-platform command-line companion for native conda. It wraps frequent but fiddly environment tasks into readable one-liners, adds safer defaults, and translates common failures into actionable hints.

Project website: wellkilo.github.io/conda-helper

✨ What it helps with

  • Back up environments to timestamped YAML files.
  • Restore from any backup with optional name override.
  • Clone environments without memorising long Conda flags.
  • Pack offline archives with conda-pack when available.

🛡️ Why it feels better

  • Batch remove stale environments safely.
  • Purge caches with dry-run support.
  • Doctor command for health checks and missing optional tools.
  • Friendly errors for network, channel, disk, and permission issues.

conda-helper does not replace Conda. It composes Conda into a smoother workflow for algorithm engineers, research engineers, and anyone who manages many local environments.


中文

conda-helper 是一个轻量、跨平台的 Conda 命令行增强工具。它基于原生 conda 封装常用环境管理动作,把繁琐命令变成清晰的一行命令,并提供更友好的错误提示与交互式面板。

项目介绍网站:wellkilo.github.io/conda-helper

✨ 适合解决什么问题

  • 备份环境:自动生成带时间戳的 YAML 文件。
  • 恢复环境:从备份文件重建环境,并支持改名。
  • 克隆环境:无需记忆复杂的 Conda 参数。
  • 离线打包:优先使用 conda-pack 生成可迁移归档。

🛡️ 为什么更顺手

  • 批量删除:一次清理多个废弃环境。
  • 缓存清理:支持 dry-run,先看结果再执行。
  • 健康检查:检测 Conda 配置和可选依赖。
  • 友好报错:把网络、源、磁盘、权限问题翻译成行动建议。

conda-helper 不替代 Conda,而是把 Conda 常用能力组合成更适合日常研发、算法实验和迁移部署的工作流。


Highlights / 功能亮点

Capability / 能力 Command / 命令 Benefit / 收益
Environment list / 环境列表 conda-helper ls Show prefix and on-disk size / 展示路径与磁盘占用
Versioned backup / 版本化备份 conda-helper backup my_env Timestamped YAML / 自动生成时间戳 YAML
Portable backup / 可移植备份 conda-helper backup my_env --from-history Export explicit packages only / 只导出主动安装包
Restore / 恢复 conda-helper restore env.yml -n my_env_v2 Rebuild with name override / 支持恢复时改名
Clone / 克隆 conda-helper clone src dst Wrapper over native clone / 封装原生克隆能力
Offline pack / 离线打包 conda-helper pack my_env -o ./dist/ Prefer conda-pack, fallback to tarball / 优先可迁移打包
Batch remove / 批量删除 conda-helper rm old_env exp_env --yes Remove multiple envs / 一次删除多个环境
Cache purge / 缓存清理 conda-helper purge --dry-run Preview reclaimable space / 先预览再清理
Health check / 健康检查 conda-helper doctor Detect broken config and optional deps / 检测配置与依赖
Interactive panel / 交互面板 conda-helper panel TTY menu for guided operations / 适合不想记参数的用户

Installation / 安装

Install from PyPI / 从 PyPI 安装
pip install conda-helper
Install from source / 从源码安装
git clone https://github.com/wellkilo/conda-helper.git
cd conda-helper
pip install -e .
Optional offline packing dependency / 可选离线打包依赖
conda install -n base -c conda-forge conda-pack

conda-helper pack works best with conda-pack. If it is not installed, the tool falls back to a plain tarball with metadata, which should only be restored on identical OS/architecture hosts.

conda-helper pack 配合 conda-pack 效果最佳。如果未安装,将回退为普通 tarball + 元数据,这种方式只建议在相同系统与架构的机器之间恢复。

Verify the installation / 验证安装:

conda-helper --version
conda-helper doctor

Quick Start / 快速开始

# List environments with on-disk size
# 查看环境列表与磁盘占用
conda-helper ls

# Back up an environment to the default backup directory
# 备份环境到默认备份目录
conda-helper backup my_env

# Export only explicitly requested packages for better portability
# 只导出主动安装的包,跨平台迁移更友好
conda-helper backup my_env --from-history

# Restore on another machine and rename the environment
# 在另一台机器恢复,并重命名环境
conda-helper restore ./my_env-20260601-101530.yml -n my_env_v2

# Clone an environment
# 克隆环境
conda-helper clone my_env my_env_copy

# Pack for an offline server
# 打包到离线服务器
conda-helper pack my_env -o ./dist/

# Remove stale environments and reclaim disk space
# 批量删除旧环境并清理缓存
conda-helper rm legacy_env exp_2023 --yes
conda-helper purge

Prefer a guided UI? / 更喜欢交互式界面?

conda-helper panel

Command Reference / 命令速查

Long form / 完整命令 Short / 短命令 Description / 说明
conda-helper ls ch l List envs with size and prefix. Use --json for machine output. / 列出环境、大小与路径,可用 --json 输出机器可读格式。
conda-helper backup <name> ch b Export to versioned YAML. Add --from-history for portable backups. / 导出带版本的 YAML,可加 --from-history 增强可移植性。
conda-helper restore <yaml> ch r Recreate from YAML. Use -n to rename. / 从 YAML 重建环境,可用 -n 改名。
conda-helper clone <src> <dst> ch c Wraps conda create --clone. / 封装原生克隆能力。
conda-helper pack <name> ch pk Build offline archive, preferring conda-pack. / 构建离线归档,优先使用 conda-pack
conda-helper rm <names...> Batch remove with confirmation. Add --yes to skip prompt. / 批量删除环境,使用 --yes 跳过确认。
conda-helper purge ch p Run conda clean --all; supports --dry-run. / 清理 Conda 缓存,支持 --dry-run
conda-helper doctor Health check and missing-tool detector. / 健康检查与可选工具检测。
conda-helper panel Interactive menu, TTY only. / 交互式菜单,仅支持 TTY。

Run the following for full flags / 查看完整参数:

conda-helper <cmd> -h

Friendly Errors / 友好错误提示

When a Conda call fails, conda-helper parses stderr and appends a hint.

当 Conda 调用失败时,conda-helper 会解析 stderr,并附加更容易行动的建议。

$ conda-helper restore env.yml
`conda env create -n my_env -f env.yml` failed with exit code 1.
stderr: CondaHTTPError: HTTP 000 CONNECTION FAILED for url ...
hint: Network problem talking to the channel. Check VPN/proxy or
      switch to a mirror (e.g. TUNA, USTC).

You can add custom rules in conda_helper/errors.py.

也可以在 conda_helper/errors.py 中添加自定义错误规则。


Cross-platform Notes / 跨平台说明

Platform / 平台 Conda discovery / Conda 查找逻辑 Default backup directory / 默认备份目录
Windows CONDA_EXE → PATH → common install directories %LOCALAPPDATA%\conda-helper\backups
macOS CONDA_EXE → PATH → ~/miniconda3/bin/conda / ~/anaconda3/bin/conda ~/Library/Application Support/conda-helper/backups
Linux CONDA_EXE → PATH → ~/miniconda3/bin/conda / /opt/conda/bin/conda ~/.local/share/conda-helper/backups

Why Another Tool? / 为什么还需要一个工具?

Existing tool / 现有工具 Gap / 痛点 How conda-helper helps / 如何补足
conda env export No backup convention or restore verb. / 缺少备份目录规范与恢复语义。 Adds timestamped backups and restore workflow. / 提供时间戳备份与恢复流程。
conda-pack Excellent for packing, but only packing. / 打包很强,但能力单一。 Combines pack with list, backup, clone, clean, and doctor. / 与列表、备份、克隆、清理、检查组合。
conda clean Easy to misuse in scripts. / 脚本中不够直观。 Adds a friendlier purge command with dry-run support. / 提供更清晰的清理命令与预览。
Native conda Verbose flags and cryptic stack traces. / 参数冗长,报错不友好。 Provides aliases, panel UI, and actionable hints. / 提供短命令、面板与行动建议。

Development / 开发

git clone https://github.com/wellkilo/conda-helper.git
cd conda-helper
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e .[dev]
pytest -q

The test suite stubs out the Conda binary, so it can run without creating or destroying real environments. CI is designed for Ubuntu, macOS, and Windows across multiple Python versions.

测试会 stub Conda 二进制文件,因此不会真实创建或删除环境。CI 设计覆盖 Ubuntu、macOS、Windows 与多个 Python 版本。

Useful project files / 常用项目文件:


Roadmap / 路线图

  • conda-helper sync — diff two environments and patch one to match. / 对比两个环境并同步差异。
  • Plugin system for custom error-translation rules. / 支持自定义错误翻译规则插件。
  • rich-powered panel as an optional extra. / 可选引入 rich 增强面板体验。
  • Lockfile-aware backups for reproducible CI builds. / 支持 lockfile 感知备份,提升 CI 可复现性。

PRs are welcome. See docs/contributing.md.

欢迎提交 PR,详见 docs/contributing.md


License / 许可证

MIT © wellkilo. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conda_helper-0.1.0.tar.gz (25.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

conda_helper-0.1.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file conda_helper-0.1.0.tar.gz.

File metadata

  • Download URL: conda_helper-0.1.0.tar.gz
  • Upload date:
  • Size: 25.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for conda_helper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3b1e36f8300ae82110b846fcf46dd833fa9039db02cd801954ba93324ccc3e15
MD5 f63de7afe073032dcfce2173e9ab60da
BLAKE2b-256 48a1ee1c0e5c600f1a9d0a29dfa4091a387c079a97174cc9d65120c88616d648

See more details on using hashes here.

Provenance

The following attestation bundles were made for conda_helper-0.1.0.tar.gz:

Publisher: publish.yml on wellkilo/conda-helper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file conda_helper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: conda_helper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for conda_helper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 239357138c649373226096021d35bde719428b0aeaa79660f5a1a9d4775aed45
MD5 d89758914618c182d1f4fe731ea88a53
BLAKE2b-256 a090b5f627cd7ccc6524d57b504eeb9c0fecbb49d335bc73994ed8c3b07599ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for conda_helper-0.1.0-py3-none-any.whl:

Publisher: publish.yml on wellkilo/conda-helper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page