conda activate激活环境出错的解决办法

出现错误情况:

今天在使用Anaconda激活python3.6环境的时候出现了如下错误:

[zsq@localhost ~]$ conda activate python36

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'.
————————————————
版权声明:本文为CSDN博主「云外孤鸟」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_33825817/article/details/88959785

google一番发现了几个解决办法,但是还是没能成功解决。后面仔细想想,发现是上次ssh连接该服务器使用conda activate python36命令激活环境后未使用conda deactivate退出环境就关闭终端导致的。

发现这个问题后,解决思路就比较明显了,重新激活一下环境就好了,具体操作如下:

# 重新进入虚拟环境
source activate
# 退出虚拟环境
conda deactivate

最后,重新执行conda activate python36,没有报错,成功进入该虚拟环境。

原文地址:https://www.cnblogs.com/shuimuqingyang/p/14703883.html