Linux安装Mamba 并 配置环境变量

17 篇文章 0 订阅

一 下载

curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh

# or

wget "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh"
bash Miniforge3-$(uname)-$(uname -m).sh

# Uninstall 以下内容来自官网
# https://github.com/conda-forge/miniforge
Uninstalling Miniforge means removing the files that were created during the installation process. You will typically want to remove:

Any modifications to your shell rc files that were made by Miniforge:
# Use this first command to see what rc files will be updated
conda init --reverse --dry-run
# Use this next command to take action on the rc files listed above
conda init --reverse
# Temporarily IGNORE the shell message
#       'For changes to take effect, close and re-open your current shell.',
# and CLOSE THE SHELL ONLY AFTER the 3rd step below is completed.

Remove the folder and all subfolders where the base environment for Miniforge was installed:
CONDA_BASE_ENVIRONMENT=$(conda info --base)
echo The next command will delete all files in ${CONDA_BASE_ENVIRONMENT}
# Warning, the rm command below is irreversible!
# check the output of the echo command above
# To make sure you are deleting the correct directory
rm -rf ${CONDA_BASE_ENVIRONMENT}

二 环境变量

如果是在自己的HOME目录下一般是不需要这步,直接配置~/.bashrc

ln -s /home/woodman/miniforge3/bin/mamba /home/woodman/anaconda3/bin/mamba

cat ~/.bashrc

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
  . /etc/bashrc
fi

if [ -f /home/woodman/.bash_aliases ]; then
    . /home/woodman/.bash_aliases
fi
# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
if [ -d ~/.bashrc.d ]; then
  for rc in ~/.bashrc.d/*; do
    if [ -f "$rc" ]; then
      . "$rc"
    fi
  done
fi

unset rc
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/woodman/miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/woodman/miniforge3/etc/profile.d/conda.sh" ]; then
        . "/home/woodman/miniforge3/etc/profile.d/conda.sh"
    else
        export PATH="/home/woodman/miniforge3/bin:$PATH"
    fi
fi
unset __conda_setup

if [ -f "/home/woodman/miniforge3/etc/profile.d/mamba.sh" ]; then
    . "/home/woodman/miniforge3/etc/profile.d/mamba.sh"
fi
# <<< conda initialize <<<
source /home/woodman/anaconda3/bin/activate
conda deactivate
conda deactivate

# TIME
export LC_TIME='en_US.UTF-8'
export PS1="[\W]$ "

### 如何在WSL上配置和使用Mamba环境管理工具 #### 启用适用于Linux的Windows子系统安装Linux分发版 为了能够在Windows 10上运行Linux应用程序,必须先启用“适用于 Linux 的 Windows 子系统”这一可选功能[^2]。完成此操作之后,可以从Microsoft Store下载所需的Linux发行版本。 #### 安装Miniconda或Anaconda 考虑到Mamba是Conda的一个替代品,因此首先需要拥有一个Conda的基础环境。推荐的方式是在WSL内安装轻量级的Miniconda而非完整的Anaconda来减少不必要的资源占用: ```bash wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh bash ~/miniconda.sh -b -p $HOME/miniconda echo 'export PATH="$HOME/miniconda/bin:$PATH"' >> ~/.bashrc source ~/.bashrc ``` 上述命令会下载最新版本的Miniconda到用户的家目录下,执行安装脚本将其放置于`$HOME/miniconda`路径中;最后一步则是将新加入的Conda二进制文件夹添加至系统的环境变量里以便随时调用[^3]。 #### 使用Conda创建初始环境向其中添加Mamba包管理器 一旦有了基本的工作空间,则可以利用现有的Conda来构建一个新的虚拟环境mamba作为依赖项之一纳入进来: ```bash conda create --name myenv python=3.9 mamba -c conda-forge conda activate myenv ``` 这里选择了Python 3.9作为解释器的具体实现形式,同时也指定了从`conda-forge`频道获取软件包以确保获得最新的稳定发布版本[^4]。 #### 替代方案:借助FastSetup加速部署流程 如果希望进一步简化整个过程的话,还可以考虑采用名为fastsetup的辅助工具来进行批量处理。这个程序能够帮助用户迅速建立起一套预设好的开发平台,其中包括但不限于Mamba在内的多种实用组件均已被集成进去等待激活: ```bash git clone https://github.com/fastai/fastsetup.git cd fastsetup ./ubuntu-setup.sh wsl ``` 这段指令序列将会克隆fastsetup项目的仓库副本到本地机器上面,接着切换进入对应的文件夹位置通过执行特定参数下的shell脚本来触发一系列自动化任务——这其中自然也就涵盖了前面提到过的各项准备工作。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值