【问题标题】:Your shell has not been properly configured to use 'conda activate'您的 shell 未正确配置为使用“conda activate”
【发布时间】:2022-01-12 20:56:30
【问题描述】:

我在持续集成中运行以下命令(不是在本地机器上):

conda env create -f python/env/foo.yml && conda init bash && conda activate foo

但是,我收到以下错误:

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


Error: Process completed with exit code 1.

既然是CI,又不能在CI中打开新的shell,那我怎么有同样的效果,才能使用conda activate呢?

【问题讨论】:

  • conda 必须配置为使用 CI 工具。您可以调查以查看您的 ENV 的外观并将conda 设置为这样。可能您使用的是 Ubuntu 或其他发行版。每个发行版都有自己的约定,您的流程是从 CI 工具的流程中分叉出来的……因此您可以进行逆向工程并使其工作,但需要频道中的更多信息才能提供帮助。
  • 我正在使用 github ci。如何为此配置 conda。并且还使用 Ubuntu。还尝试在 conda init bash 之后执行 source ~/.bashrc,但仍然出现相同的错误。

标签: shell continuous-integration conda


【解决方案1】:

conda init 命令用于向 shell 资源文件添加代码,为交互式 shell 会话提供功能(如 conda activate)。由于 CI 会话通常是短暂的,因此应该直接获取 etc/profile.d/conda.sh 以添加 conda activate 支持。

类似:

conda env create -f python/env/foo.yml \
  && . "$(conda info --base)/etc/profile.d/conda.sh" \
  && conda activate foo

【讨论】:

    猜你喜欢
    • 2020-09-06
    • 2021-12-30
    • 1970-01-01
    • 2019-04-22
    • 1970-01-01
    • 1970-01-01
    • 2022-06-18
    • 2022-01-08
    相关资源
    最近更新 更多