首页 > 解决方案 > 激活 conda env 并在 Dockfile 中运行 pip install 要求

问题描述

我可以成功创建我的虚拟环境dev1,但是在 Docker 构建期间我无法激活它并切换到它。

我想要的只是切换 venv 并将我的依赖项安装在requirements.txt.

我的代码:

WORKDIR /APP
ADD . /APP
ARG CONDA_VENV=dev1
RUN conda create -y --name ${CONDA_VENV} python=3.7
RUN conda activate ${CONDA_VENV}
RUN pip install -r requirements.txt

错误:

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


The command '/bin/sh -c conda activate ${CONDA_VENV}' returned a non-zero code: 1

标签: dockeranacondadockerfilecondadocker-build

解决方案


推荐阅读