我正在使用 docker 制作 anaconda3 环境。
但是它显示如下错误。
我想这与一些 shell 问题有关..但我还不能修复。
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'.
我的 dockerfile 在这里。
FROM ubuntu:18.04
RUN apt-get -y update
RUN apt-get -y install emacs wget
RUN wget https://repo.continuum.io/archive/Anaconda3-2019.07-Linux-x86_64.sh
RUN /bin/bash Anaconda3-2019.07-Linux-x86_64.sh -b -p $HOME/anaconda3
RUN echo 'export PATH=/root/anaconda3/bin:$PATH' >> /root/.bashrc
#RUN source /root/.bashrc
RUN . /root/.bashrc
RUN /root/anaconda3/bin/conda init bash
RUN /root/anaconda3/bin/conda create -n py37 python=3.7 anaconda
RUN /root/anaconda3/bin/conda activate py37
最佳答案
我相信您的问题可能是您正在采购 .bashrc
在与依赖它的命令不同的行中。来自 Dockerfile documentation :
The RUN instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile.
这意味着您正在采购您的
.bashrc
在一层(第一个 RUN
行),然后是 RUN
宁conda
中的命令新品 层,对上一层中的环境一无所知。尝试这样的事情:
RUN . /root/.bashrc && \
/root/anaconda3/bin/conda init bash && \
/root/anaconda3/bin/conda create -n py37 python=3.7 anaconda && \
/root/anaconda3/bin/conda activate py37
通过在一行上运行它们,您是在单个层中运行它们。
关于python - 您的 shell 尚未正确配置为在 dockerfile 上使用 'conda activate',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60855061/