【发布时间】:2020-01-22 09:55:00
【问题描述】:
当我在 Bash 脚本中激活 Conda 环境时:
#!/bin/bash
conda activate ./myenv
which python
python do_stuff.py
activate 行打印出长警告:
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'.
如何消除此警告?如果我运行它建议的conda init bash 命令,这会导致 Conda 默认为所有 Bash shell 激活我的环境,这绝对不是我想要的。这是 Conda 中的默认配置,在它破坏了我系统中各处的功能后,我明确将其关闭。我希望 Conda 的功能类似于 virtualenv,其中我有一个包含环境的文件夹,并且仅在特定应用程序需要时才激活它。在任何情况下,我都不希望为系统上任何地方运行的每个 Bash 实例激活 Conda 环境。
我不确定为什么它给了我一个 CommandNotFoundError,因为否则 Conda 会使用 Python 和其他特定环境资源的正确路径填充我的 Bash shell,并且其他一切都正常工作。
【问题讨论】: