在Ubuntu18.04终端想激活一个conda虚拟环境时,输入命令conda activate gluon时出现错误提示:
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'.
但如果是用source activate gluon就能正常激活,反复几次之后发现每次重启终端都需要用source才能激活,用过source之后的同一个终端下才能用conda激活。
随后根据报错提示,重新配置conda的shell环境(本文用的是bash):conda init bash
执行命令后:
tsy@tsy-OMEN-Laptop-15-ek0xxx:~$ conda init bash
no change /home/tsy/anaconda3/condabin/conda
no change /home/tsy/anaconda3/bin/conda
no change /home/tsy/anaconda3/bin/conda-env
no change /home/tsy/anaconda3/bin/activate
no change /home/tsy/anaconda3/bin/deactivate
no change /home/tsy/anaconda3/etc/profile.d/conda.sh
no change /home/tsy/anaconda3/etc/fish/conf.d/conda.fish
no change /home/tsy/anaconda3/shell/condabin/Conda.psm1
no change /home/tsy/anaconda3/shell/condabin/conda-hook.ps1
no change /home/tsy/anaconda3/lib/python3.6/site-packages/xontrib/conda.xsh
no change /home/tsy/anaconda3/etc/profile.d/conda.csh
modified /home/tsy/.bashrc
==> For changes to take effect, close and re-open your current shell. <==
重启终端后,默认环境会显示是base,然后再执行conda activate gluon就能正常激活啦!
(base) tsy@tsy-OMEN-Laptop-15-ek0xxx:~$ conda activate gluon
(gluon) tsy@tsy-OMEN-Laptop-15-ek0xxx:~$