我需要在一个带有bash脚本的chroot的Anaconda Python环境中运行命令,如下所示:
# install miniconda
chroot $chroot_path /bin/bash /miniconda.sh -f -b -p /miniconda
# Install packages in py2 environment
chroot $chroot_path /bin/bash source /miniconda/bin/activate py2 && /miniconda/bin/conda install notebook ipykernel
但我明白了:
/bin/bash: source: No such file or directory
如何让它发挥作用?
答案 0 :(得分:1)
此命令有两个问题
chroot $chroot_path /bin/bash source /miniconda/bin/activate py2 && /miniconda/bin/conda install notebook ipykernel
首先,source
是bash
关键字,而不是可执行程序。执行/bin/bash source /miniconda/bin/activate py2
时,您正在尝试运行不存在的可执行文件,该文件失败。其次,&&
之后的部分只会在chroot退出后运行。相反,您可以使用-c
将该行作为脚本运行
chroot $chroot_path /bin/bash -c "source /miniconda/bin/activate py2;/miniconda/bin/conda install notebook ipykernel"