报错:CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate‘. 问题解决

今天在VS code里跑一个小网络,想先切换conda环境,发现无法切换了,并提示报错为:

PS E:\XXX> conda activate XXXXX

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

To initialize your shell, run

    $ conda init 

Currently supported shells are:
  - bash
  - cmd.exe
  - 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'.

查了下原因,大概意思是初次使用Anaconda时,没有预先对命令行进行预载。解决办法非常简单,在上文报错的提示中也说明了,根据提示运行对应的命令即可

conda init {TERMINAL_TYPE}

即,在windows下,终端中输入

conda init cmd.exe

在linux下,终端中输入

conda init bash

在VScode中,我使用了powershell,运行结束后重启终端应该就能解决

如果还是不行,就参考这个:VSCode激活conda虚拟环境_丸子爱学习!的博客-CSDN博客_vscode激活虚拟环境

你可能感兴趣的:(python,linux,ubuntu)