[오류 노트] CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.

정준환·2022년 11월 15일
3

상황


linux 환경에서 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'.

일단 하라는 대로 $ conda init bash 를 실행했다.

no change     /opt/conda/condabin/conda
no change     /opt/conda/bin/conda
no change     /opt/conda/bin/conda-env
no change     /opt/conda/bin/activate
no change     /opt/conda/bin/deactivate
no change     /opt/conda/etc/profile.d/conda.sh
no change     /opt/conda/etc/fish/conf.d/conda.fish
no change     /opt/conda/shell/condabin/Conda.psm1
no change     /opt/conda/shell/condabin/conda-hook.ps1
no change     /opt/conda/lib/python3.8/site-packages/xontrib/conda.xsh
no change     /opt/conda/etc/profile.d/conda.csh
no change     /opt/ml/.bashrc
No action taken.

변경 사항은 없었고, 껐다 켜도 해결이 되지 않았다.

해결 방법


나는 두가지 방법으로 문제를 해결할 수 있었다.

1. conda 대신 source 명령어 사용하기

간단하게
$ conda activate <env_name> 대신
$ source activate <env_name> 을 사용하니 해결됐다.
아래 링크를 보면 권장되는 방법은 아닌 것 같다.
https://stackoverflow.com/questions/49600611/python-anaconda-should-i-use-conda-activate-or-source-activate-in-linux

2. $ source conda.sh 명령어 사용하기

conda.sh가 있는 경로를 알아야한다. 보통 아래 둘 중 하나에 있다.
~/Anaconda3/etc/profile.d/conda.sh ~/miniconda3/etc/profile.d/conda.sh
나같은 경우는 서버를 빌려서 쓰고 있는데, ~/../conda/etc/profile.d/conda.sh 여기에 존재했다.

해당 파일을 찾아 source 명령어를 실행해주면 된다.
$ source ~/Anaconda3/etc/profile.d/conda.sh
$ source ~/miniconda3/etc/profile.d/conda.sh
$ source ~/../conda/etc/profile.d/conda.sh

자신의 상황에 맞게 파일을 찾아서 해보자. 이후 $ conda activate <env_name>을 하면 잘 된다!

profile
정준환

0개의 댓글