【问题标题】:"conda activate" in .bash_profile adds error message with unknown consequences.bash_profile 中的“conda activate”添加了具有未知后果的错误消息
【发布时间】:2019-11-23 17:17:32
【问题描述】:

当我在我的 Mac OS 中打开一个终端窗口(现在使用 Catalina,但在升级之前得到相同的行为)时,我收到以下消息 3 次:

Last login: Sat Nov 23 11:38:00 on ttys001
ERROR: The install method you used for conda--probably either `pip install conda`
or `easy_install conda`--is not compatible with using conda as an application.
If your intention is to install conda as a standalone application, currently
supported install methods include the Anaconda installer and the miniconda
installer.  You can download the miniconda installer from
https://conda.io/miniconda.html.

.bash_profile文件有以下内容:

conda activate
conda activate
conda activate
# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<

我怀疑conda activate 出现了三次,因为我已经安装了三次 anaconda。无论如何,如果我删除这三行并打开一个新的终端窗口,它不会抱怨。谁能解释这种行为并告诉我删除这三行的利弊?我应该删除文件的全部内容(即其他 16 行)吗?

【问题讨论】:

    标签: bash macos unix anaconda


    【解决方案1】:

    conda init 管理的代码部分是标准的,应该为您处理激活 Conda,假设 auto_activate_base 设置为 true,这是默认设置(您可以使用 conda config --show auto_activate_base 检查)。我建议删除这三个 conda activate 行,因为它们不是必需的,而且根据我的经验也不是标准的。

    虽然我之前已经看到用户尝试运行 pip install conda 的错误消息,但我真的不知道您为什么会在这种情况下看到它。在我的系统上,尝试在conda init 部分之前引用conda 会导致command not found 错误。也许您正在手动将 Conda bin/ 目录添加到 PATH,自 Conda v4.4 以来一直不鼓励这样做(请参阅 Release Notes)。

    【讨论】:

    • 感谢您的回答。我确实尝试过pip install conda。所以这可能是文件中引入这些行的原因。我现在再次尝试查看是否可以重现该行为,但它没有发生......我没有手动添加到PATH 任何东西。但是,现在我的计算环境不同了:当这些线条出现时,我的操作系统不同,而 Conda 停止工作......
    • @BrianBarcelona 感谢您的反馈。我将在答案中留下关于 PATH 的评论,即使它不适用于您,以防万一它可能与访问此问题的其他人有关。
    • 听起来很完美。我确实发现您提到的发行说明 (github.com/conda/conda/releases/tag/4.4.0) 提供了很多信息。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 2020-01-31
    • 2020-10-16
    • 1970-01-01
    • 2019-11-23
    • 2021-09-03
    相关资源
    最近更新 更多