【问题标题】:Error when activating Anaconda in Git Bash在 Git Bash 中激活 Anaconda 时出错
【发布时间】:2021-01-18 01:54:56
【问题描述】:

我正在尝试从 Win10 中的 Git Bash 激活 Anaconda 环境。奇怪的是,它一开始可以工作,我设法激活了它,启动了一个 jupyter 笔记本并在笔记本中运行 bash 命令(我的目标)。

但是,现在我在下面收到此错误:

$ source /c/ProgramData/Anaconda3/Scripts/activate
bash: eval: line 57: syntax error near unexpected token `('
bash: eval: line 57: `PS1=''(Anaconda3)'\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ ''

我的activate脚本的内容是:

#!/bin/sh
_CONDA_ROOT="C:/ProgramData/Anaconda3"
\. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
conda activate "$@"

我认为与conda.sh相关的功能:

__conda_activate() {
    if [ -n "${CONDA_PS1_BACKUP:+x}" ]; then
        # Handle transition from shell activated with conda <= 4.3 to a subsequent activation
        # after conda updated to >= 4.4. See issue #6173.
        PS1="$CONDA_PS1_BACKUP"
        \unset CONDA_PS1_BACKUP
    fi

    \local cmd="$1"
    shift
    \local ask_conda
    OLDPATH="${PATH}"
    __add_sys_prefix_to_path
    # The below is line 57 in the original file:
    ask_conda="$(PS1="$PS1" "$CONDA_EXE" $_CE_M $_CE_CONDA shell.posix "$cmd" "$@")" || \return $?
    PATH="${OLDPATH}"
    \eval "$ask_conda"
    __conda_hashr
}

任何帮助指出如何解决这个问题?

【问题讨论】:

    标签: anaconda git-bash


    【解决方案1】:

    找到导致错误的原因。在~/.condarc 文件中,这一行似乎与从 bash 激活的冲突:

    env_prompt: "'({name})'"

    刚刚注释掉它并且很好地激活了。

    关于信息,该行的目的是在使用 --prefix &lt;path&gt; 选项激活环境时仅显示目录的名称。

    【讨论】:

      猜你喜欢
      • 2019-08-28
      • 1970-01-01
      • 2019-08-19
      • 2021-10-06
      • 2019-06-07
      • 2023-03-24
      • 1970-01-01
      • 2021-12-27
      • 2012-05-14
      相关资源
      最近更新 更多