linux - 执行命令时出错:Linux EC2 实例上的 conda activate 命令
问题描述
作为管道的一部分,我正在 AWS 上构建构建服务器。我正在使用一个 buildspec 文件,该文件在我的代码复制到 linux 实例后运行以下命令,使用图像 (aws/codebuild/amazonlinux2-x86_64-standard:2.0):
- echo 'Install Conda to run python'
- echo 'Download conda from web'
- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
- echo 'Install miniconda'
- sh ~/miniconda.sh -b -p $HOME/miniconda
- eval "$(~/miniconda/bin/conda shell.bash hook)"
- echo 'cd to outbound and list'
- cd outbound
- echo 'create conda environment'
- conda env create -f environment_droplet.yml
- conda env list
- bash
- conda init bash
- echo "conda activate calme" >> ~/.bash_profile
- echo ". ~/miniconda/etc/profile.d/conda.sh" >> ~/.bash_profile
- echo "export PATH=~/miniconda/bin:$PATH" >> ~/.bash_profile
- . ~/.bash_profile
- exec bash
- conda init bash
- conda activate calme
但是,最后一个命令 'conda activate 不成功并导致错误:
[Container] 2020/08/30 20:38:14 Running command conda init bash
no change /root/miniconda/condabin/conda
no change /root/miniconda/bin/conda
no change /root/miniconda/bin/conda-env
no change /root/miniconda/bin/activate
no change /root/miniconda/bin/deactivate
no change /root/miniconda/etc/profile.d/conda.sh
no change /root/miniconda/etc/fish/conf.d/conda.fish
no change /root/miniconda/shell/condabin/Conda.psm1
no change /root/miniconda/shell/condabin/conda-hook.ps1
no change /root/miniconda/lib/python3.8/site-packages/xontrib/conda.xsh
no change /root/miniconda/etc/profile.d/conda.csh
no change /root/.bashrc
No action taken.
[Container] 2020/08/30 20:38:14 Running command conda activate calme
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'.
[Container] 2020/08/30 20:38:14 Command did not exit successfully conda activate calme exit status 1
[Container] 2020/08/30 20:38:14 Phase complete: PRE_BUILD State: FAILED
[Container] 2020/08/30 20:38:14 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: conda activate calme. Reason: exit status 1
如您所见,从我的 buildspec 片段中,我正在重新加载 .bash_profile,应用 conda init bash 并创建一个新的 bash 实例。我相信上述所有命令都将有助于重置现有终端,因此 conda activate 是公认的命令 - 但事实并非如此。创建独立 EC2 实例时我没有这个问题,因为我可以重新启动终端/关闭连接并重新连接。但是,我需要能够通过 buildspec 和为项目构建创建的 ec2 实例激活 conda。任何帮助表示赞赏
解决方案
推荐阅读
- c# - Azure 持久函数“terminatePostUri”在触发时给出 404
- pytorch - 仅针对 Pytorch 中的前端网络计算梯度
- javascript - 如何在 createStructuredSelector 中传递 arg 重新选择
- javascript - ThreeJS 将 GLTF 模型与边界框的大小匹配
- java - Firebase 从 Firebase 实时数据库中的 2 个级别检索数据
- python-3.x - 得到一个错误'bool'对象是不可迭代的
- c++ - 使用 wxWidgets 创建 cmake
- powershell - 使用powershell在线将文档库复制到文档库共享点
- gcc - x86-64 上 source-gcc/gcc/real.[c\h] 测试下的 GCC 二进制浮点转换
- scopus - 是否可以将隶属关系历史与研究人员在给定机构任职的年份配对,因为它出现在 scopus 网站上?