我的任务是创建一个bash文件,从原始存储库中安装了Conda,然后我必须激活它才能降级python版本或安装一些软件包(使用conda),例如graphviz或pygraphviz。 所有这些都要求在单个bash文件中完成,但如果无法在多个bash文件中完成,则尝试减少用户需要键入的命令数量(以便任何员工都可以下载)整个环境)
我在https://askubuntu.com/questions/849470/how-do-i-activate-a-conda-environment-in-my-bashrc中看到了一些答案,但没有一个对我的环境有用。
#!/bin/bash
if [ "$(whoami)" != "root" ]
then
echo "Root privileges needed."
exit 1
fi
echo "Initiating conda installation...!"
dpkg --configure -a
cd /tmp
curl -O https://repo.anaconda.com/archive/Anaconda3-2019.03-Linux-x86_64.sh
echo -ne '\nyes\n\nyes' | bash $(dirname "$0")/Anaconda3-2019.03-Linux-x86_64.sh
source ~/.bashrc
conda install python=3.6.2
我的目标是,一旦下载了它,就可以从输出中获取它,并将其保留在.bashrc中,然后在同一bash脚本中使用conda命令安装Python。我该怎么做? 我现在得到的输出是:
installing: pytest-doctestplus-0.3.0-py37_0 ...
installing: pywavelets-1.0.2-py37hdd07704_0 ...
installing: scipy-1.2.1-py37h7c811a0_0 ...
installing: bkcharts-0.2-py37_0 ...
installing: dask-1.1.4-py37_1 ...
installing: patsy-0.5.1-py37_0 ...
installing: pytables-3.5.1-py37h71ec239_0 ...
installing: pytest-astropy-0.5.0-py37_0 ...
installing: scikit-image-0.14.2-py37he6710b0_0 ...
installing: scikit-learn-0.20.3-py37hd81dba3_0 ...
installing: astropy-3.1.2-py37h7b6447c_0 ...
installing: statsmodels-0.9.0-py37h035aef0_0 ...
installing: seaborn-0.9.0-py37_0 ...
installing: anaconda-2019.03-py37_0 ...
installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> WARNING: The conda.compat module is deprecated and will be removed in a future release.
no change /home/developer/anaconda3/condabin/conda
no change /home/developer/anaconda3/bin/conda
no change /home/developer/anaconda3/bin/conda-env
no change /home/developer/anaconda3/bin/activate
no change /home/developer/anaconda3/bin/deactivate
no change /home/developer/anaconda3/etc/profile.d/conda.sh
no change /home/developer/anaconda3/etc/fish/conf.d/conda.fish
no change /home/developer/anaconda3/shell/condabin/Conda.psm1
no change /home/developer/anaconda3/shell/condabin/conda-hook.ps1
no change /home/developer/anaconda3/lib/python3.7/site-packages/xonsh/conda.xsh
no change /home/developer/anaconda3/etc/profile.d/conda.csh
no change /home/developer/.bashrc
No action taken.
If you'd prefer that conda's base environment not be activated on startup,
set the auto_activate_base parameter to false:
conda config --set auto_activate_base false
Thank you for installing Anaconda3!
===========================================================================
Anaconda and JetBrains are working together to bring you Anaconda-powered
environments tightly integrated in the PyCharm IDE.
PyCharm for Anaconda is available at:
https://www.anaconda.com/pycharm
./environment_set_test.sh: line 22: conda: command not found
这是安装后的.bashrc:
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/developer/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/developer/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/developer/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/developer/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<