CommandNotFoundError:您的shell尚未正确配置为使用Conda Activate' [英] CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'

查看:95
本文介绍了CommandNotFoundError:您的shell尚未正确配置为使用Conda Activate'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Colboratory上的Conda创建虚拟环境。 但是,我无法激活,出现以下错误。

    CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init

我尝试过两个改进。 我尝试过三种改进。 一种是将以下代码添加到~/.bashrc。

# >>> conda init >>>
__conda_setup="$(CONDA_REPORT_ERRORS=false '$HOME/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "$HOME/anaconda3/etc/profile.d/conda.sh" ]; then
        . "$HOME/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        export PATH="$PATH:$HOME/anaconda3/bin"
    fi
fi
unset __conda_setup
# <<< conda init <<<

# ~~~~~~~~~~~~
conda create --name XXXXXX python=3.6 -y
conda activate XXXXXX 
# ~~~~~~~~~~~~

其次,我将以下代码添加到~/.bashrc

export PATH="$PYENV_ROOT/versions/anaconda3-2.5.0/bin/:$PATH"

第三,我将以下代码添加到~/.bashrc

. /opt/anaconda3/etc/profile.d/conda.sh
conda activate base

如果我尝试激活它们中的每一个,都会收到相同的错误。如果有人理解,请分享您的智慧。

谢谢

推荐答案

答案如下: https://github.com/conda/conda/issues/7980

source ~/anaconda3/etc/profile.d/conda.sh
conda activate my_env

可能您也使用了错误的anaconda/miniconda路径。 使用此命令产生的命令:

conda info | grep -i 'base environment'

:)

这篇关于CommandNotFoundError:您的shell尚未正确配置为使用Conda Activate&#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆