Ubuntu24.04.4安装miniforge+mamba替代miniconda 一、前置依赖sudo apt update sudo apt install wget curl bash -y二、下载安装脚本1.到网站https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/2.找到最新版本例如Miniforge3-26.3.2-3-Linux-x86_64.sh3.下载wget https://mirrors.tuna.tsinghua.edu.cn/github-release/conda-forge/miniforge/LatestRelease/Miniforge3-26.3.2-3-Linux-x86_64.sh三、执行安装chmod x Miniforge3-*.shbash Miniforge3-26.3.2-3-Linux-x86_64.sh1. 回车阅读协议输入 yes 同意2. 选择安装路径默认 ~/miniforge3直接回车即可想自定义输入路径3. 是否初始化 shell输入 no。以后每次手动临时加载不修改 bashrc一次性生效eval $(~/miniforge3/bin/conda shell.bash hook) # 之后 conda / mamba 都能用关闭终端失效installation finished. Do you wish to update your shell profile to automatically initialize conda? This will activate conda on startup and change the command prompt when activated. If youd prefer that condas base environment not be activated on startup, run the following command when conda is activated: conda config --set auto_activate_base false Note: You can undo this later by running conda init --reverse $SHELL Proceed with initialization? [yes|no] [no] no You have chosen to not have conda modify your shell scripts at all. To activate condas base environment in your current shell session: eval $(/home/gysd/miniforge3/bin/conda shell.YOUR_SHELL_NAME hook) To install condas shell functions for easier access, first activate, then: conda init Thank you for installing Miniforge3! userserver1:~$四、关闭默认base自动激活推荐conda config --set auto_activate_base false查看conda config --get auto_activate_basetrue打开终端自动激活 basefalse打开终端不会自动进 base无输出代表未手动设置过使用默认值默认 true四、换国内清华源1.conda config --set show_channel_urls yes2.vi ~/.condarcchannels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/auto_activate: falseshow_channel_urls: true3.清理旧缓存: conda clean -i4.查看mamba info五、卸载 Miniforge# 删除安装目录rm -rf ~/miniforge3# 删除配置rm -rf ~/.condarc ~/.conda ~/.continuum# 删除shell初始化打开 ~/.bashrc 删除底部conda相关代码vi ~/.bashrc六、使用日常安装、创建环境、更新、导出环境 一律用 mamba;仅少数场景用conda;conda configmamba config 等效但社区习惯 conda# 修改 conda 全局配置用condaconda env list # 查看所有环境用condaconda remove -n py310 --all # 删除环境用condamamba create -n py311 python3.11 # 创建虚拟环境conda activate py311/conda deactivate #环境激活 / 退出用condamamba install pytorch torchvision -ymamba update --allmamba env export env.ymlmamba clean -i #清理旧缓存