LoginSignup
7
6

More than 5 years have passed since last update.

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. への対処法

Posted at

とあるパッケージをインストールしようとGitHubのREADME.mdのとおりに実行したところ、
以下のエラーに遭遇しました。

$ ./install.sh

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'.

中身を見てみると、

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

conda activateでエラーが出ているようです。

エラーメッセージによればconda initをすれば良い、とのなので、
Anacondaをインストールするときに~/.bashrcに書き込まれる
以下のコードをinstall.shに挿入するとうまく動くようになりました。

install_modified.sh
# ~~~~~~~~~~~~
# >>> 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 
# ~~~~~~~~~~~~

もし同じエラーが起きたときにご参考になれば幸いです。

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6