众所周知,Mamba直接用conda下载往往因为网络等问题导致失败,之前也看了有文章讲通过下载文件再安装或者在github上下载的方式,都失败了
顿悟来源于:当时文章Python笔记——linux/ubuntu下安装mamba,安装bob.learn库_mamba安装-优快云博客
提到可以从github上下载,但是输入命令后发现这个网址是空的,不过也可以旁敲侧击解决。
解决方法如下:
思路为:直接从GitHub Releases下载miniforge然后安装mamba是一个很好的替代方案。
步骤一:选择并下载Miniforge安装脚本
访问 https://github.com/conda-forge/miniforge/releases 找到最新版本的Miniforge。你需要选择与你的系统架构和Python版本相匹配的.sh文件。
例如,如果你使用的是x86_64架构,并且想要Python 3.10的Miniforge,你可能会选择类似 Miniforge3-23.1.0-4-Linux-x86_64.sh 的文件(请注意,版本号可能会更新)。
我的是在autodl的容器中下载,cuda12.4,python=3.12,输入了:(以下这个基本都可以)
wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniforge_installer.sh
步骤二:运行Miniforge安装脚本
下载完成后,需要运行这个脚本来安装Miniforge。在运行之前,给它执行权限:
chmod +x miniforge_installer.sh
./miniforge_installer.sh -b -p /root/miniforge
步骤三:初始化Conda环境
export PATH="/root/miniforge/bin:$PATH"
conda init bash
source ~/.bashrc
步骤四:安装Mamba
现在Miniforge已经安装并初始化,可以使用conda或mamba来安装mamba了。由于已经安装了Miniforge(它默认包含conda-forge作为主要频道),安装mamba会非常直接。
conda install -c conda-forge mamba
安装完成后即可以使用mamba命令了
之后有个小问题,可能会遇到
我安装后直接可以使用mamba create环境了,但是发现无法mamba activate 这个环境,
报错为:
'mamba' is running as a subprocess and can't modify the parent shell.
Thus you must initialize your shell before using activate and deactivate.
To initialize the current bash shell, run:
$ eval "$(mamba shell hook --shell bash)"
and then activate or deactivate with:
$ mamba activate
To automatically initialize all future (bash) shells, run:
$ mamba shell init --shell bash --root-prefix=~/.local/share/mamba
If your shell was already initialized, reinitialize your shell with:
$ mamba shell reinit --shell bash
Otherwise, this may be an issue. In the meantime you can run commands. See:
$ mamba run --help
Supported shells are {bash, zsh, csh, posix, xonsh, cmd.exe, powershell, fish, nu}.
critical libmamba Shell not initialized
这表明你的 shell 环境(在这个例子中是 bash)还没有被 mamba 或者 conda 正确地初始化。即使你之前运行了 conda init bash 或 source ~/.bashrc,在某些情况下(尤其是在容器或特定Autodl配置中),可能仍然需要额外的步骤来确保 mamba 的 shell hook 被正确加载。
因此在当前打开的bash中:
eval "$(mamba shell hook --shell bash)"
这是最直接的修复方法,只对你当前打开的 shell 会话有效,然后问题解决。
5375

被折叠的 条评论
为什么被折叠?



