快用 Mamba 代替 Conda

🚀 还在被 Conda 折磨?试试 Mamba 吧!

是否你在使用 conda install 安装包时总是报莫名其妙的依赖错误?
这种情况是否一直困扰着你?
是否想拥有一个更完美的包管理器呢?

快来试试 mamba 吧!


🌟 什么是 Mamba?

Mamba 是一个 conda 的加速器,完全兼容 Conda 命令行,拥有以下优点:

  • 🚀 更快的解析速度
  • 🔧 更好的依赖处理算法
  • 📦 更丰富的包支持

📦 安装 Mamba 的方法

✅ 方法一:命令行下载安装(推荐)

参考:Micromamba User Guide — documentation


🔹 步骤 1:下载安装包

根据你的操作系统选择:

Linux 系统

# Linux Intel (x86_64)
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba

# Linux ARM64
curl -Ls https://micro.mamba.pm/api/micromamba/linux-aarch64/latest | tar -xvj bin/micromamba

# Linux PowerPC
curl -Ls https://micro.mamba.pm/api/micromamba/linux-ppc64le/latest | tar -xvj bin/micromamba

macOS 系统

# macOS Intel (x86_64)
curl -Ls https://micro.mamba.pm/api/micromamba/osx-64/latest | tar -xvj bin/micromamba

# macOS Apple Silicon (ARM64)
curl -Ls https://micro.mamba.pm/api/micromamba/osx-arm64/latest | tar -xvj bin/micromamba

🔹 步骤 2:初始化环境

Linux / bash 用户:

./bin/micromamba shell init -s bash -r ~/micromamba
source ~/.bashrc  # 或者重启终端

macOS / zsh 用户:

./micromamba shell init -s zsh -r ~/micromamba
source ~/.zshrc

🔹 步骤 3:配置 Channels(使用清华源)

Micromamba 不会自动配置 channels,需要手动设置。推荐使用清华镜像源。

配置 channels:

micromamba config prepend channels conda-forge

获取配置文件路径:

micromamba config sources

编辑 .condarc 文件:

vim ~/.condarc

写入以下内容:

channels: 
  - defaults
show_channel_urls: true

default_channels: 
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2

custom_channels: 
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/

清除索引缓存:

micromamba clean -i

这样可以确保使用的是镜像源提供的索引,加速安装。


🔹 步骤 4:验证安装是否成功

micromamba --version
micromamba list

🧪 安装完成后

你就可以像使用 conda 一样使用 micromamba:

micromamba create -n myenv python=3.10
micromamba activate myenv
micromamba install numpy pandas

🎉 现在你已经成功告别 Conda 的卡顿,体验 Mamba 的丝滑速度!

posted @ 2024-01-13 19:40  wuhaoliu  阅读(363)  评论(0)    收藏  举报  来源