Python 炮弹警报

Python 炮弹警报,python,bash,conda,Python,Bash,Conda,在Bash脚本中激活Conda环境时,如: #!/bin/bash conda activate ./myenv which python python do_stuff.py 激活行打印出长警告: CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run $ conda init <SHELL_

在Bash脚本中激活Conda环境时,如:

#!/bin/bash
conda activate ./myenv
which python
python do_stuff.py
激活行打印出长警告:

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'.
CommandNotFoundError:您的shell未正确配置为使用“conda activate”。
要初始化shell,请运行
$conda init
当前支持的shell有:
-猛击
-鱼
-tcsh
-克逊什
-zsh
-动力壳
有关更多信息和选项,请参阅“conda init--help”。
重要提示:在运行“conda init”后,您可能需要关闭并重新启动shell。
我如何使这个警告保持沉默?如果我运行它建议的
conda init bash
命令,这将导致conda在默认情况下为所有bash shell激活我的环境,这绝对不是我想要的。这是Conda中的默认配置,在它破坏了整个系统的所有功能后,我明确地关闭了它。我希望Conda的功能类似于virtualenv,我有一个包含环境的文件夹,只有在特定应用程序需要时才激活它。在任何情况下,我都不希望系统中任何地方运行的Bash的每个实例都激活Conda环境


我不知道为什么它会给我一个CommandNotFoundError,因为否则Conda会用到Python和其他特定于环境的资源的正确路径填充我的Bash shell,其他一切都会正常工作。

初始化
Conda
后,它会在您打开的每个新shell会话上自动激活基本环境,默认情况下。如果要关闭此行为,只需运行一次:

conda config --set auto_activate_base false

初始化
conda
后,默认情况下,它将在您打开的每个新shell会话上自动激活基本环境。如果要关闭此行为,只需运行一次:

conda config --set auto_activate_base false

在脚本中预编以下代码

eval“$(命令conda'shell.bash'hook'2>/dev/null)

这将仅在脚本中初始化conda。

在脚本中预先添加以下代码

eval“$(命令conda'shell.bash'hook'2>/dev/null)

这将仅在脚本中初始化conda。

这样做了。谢谢,这就成功了。谢谢