conda activate命令,在命令行里运行正常,放到脚本里运行就不行,说要init。

报错如下

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init

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

 

解决办法:

https://github.com/conda/conda/issues/7980

在conda activate之前加入下面的语句。具体内容就是conda init命令之后,在.bashrc里面新增的也是这条语句。

source ~/anaconda3/etc/profile.d/conda.sh

你可能感兴趣的:(conda activate命令,在命令行里运行正常,放到脚本里运行就不行,说要init。)