【问题标题】:activating conda fails (sourcing ~/.bashrc)激活 conda 失败(采购 ~/.bashrc)
【发布时间】:2019-09-17 13:34:07
【问题描述】:

我在“Ubuntu 14.04.5 LTS”上新安装了 Anaconda (Anaconda3-2019.07-Linux-x86_64),但激活安装失败:

source ~/.bashrc 返回Illegal variable name.

cat ~/.bashrc:

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

第一行似乎是原因:__conda_setup="$('/home/scientia/anaconda3/bin/conda' 'shell.bash' 'hook' 2&gt; /dev/null)"

【问题讨论】:

  • 这正是我在.bashrc 中所拥有的。当你运行 conda activate base 时会发生什么?也许试试conda init bash?但这可能只是重写你已经在 .bashrc 中的内容。
  • 由于这个错误似乎与 shell 相关,您能否将echo $SHELL 的输出添加到问题中?

标签: shell ubuntu anaconda conda tcsh


【解决方案1】:

如您所见,.bashrc 初始化是特定于 bash 的。然而,Conda 也支持 csh/tcsh 的初始化。只需运行

/home/scientia/anaconda3/bin/conda init tcsh

然后重新启动您的 tcsh 会话,现在应该正确配置 Conda。如果您想查看它添加到 .tcshrc 的内容,可以使用详细标志 -v 运行上述代码。

【讨论】:

    【解决方案2】:

    首先,通过这个找到你的shell:

    echo $Shell
    

    如果你得到:csh,你应该输入:

    conda init tcsh
    

    或:./conda init tcsh 在~/anaconda3/bin/

    【讨论】:

      【解决方案3】:

      我发现我使用的是 tcsh shell,它不允许使用 .bashrc 中使用的语法。

      执行bash,然后进行采购。

      【讨论】:

      猜你喜欢
      • 2021-11-10
      • 1970-01-01
      • 1970-01-01
      • 2011-11-15
      • 2023-03-31
      • 2015-07-09
      • 1970-01-01
      • 2019-06-16
      • 2023-04-03
      相关资源
      最近更新 更多