在vagrant shell配置期间激活anaconda环境
我正在使用vagrant(MacOSX Sierra上的1.9.1)在VirtualBox上提供在vagrant shell配置期间激活anaconda环境,shell,vagrant,vagrantfile,vagrant-provision,miniconda,Shell,Vagrant,Vagrantfile,Vagrant Provision,Miniconda,我正在使用vagrant(MacOSX Sierra上的1.9.1)在VirtualBox上提供ubuntu/xenial64box来运行python应用程序。设置时,我无法使用普通shell命令source激活conda环境。在我的bootstrap.sh中,我有以下几行代码来创建一个新环境,然后切换到它 #!/usr/bin/env bash set -e # Exit script immediately on first error. set -x # Print commands an
ubuntu/xenial64
box来运行python应用程序。设置时,我无法使用普通shell命令source
激活conda环境。在我的bootstrap.sh
中,我有以下几行代码来创建一个新环境,然后切换到它
#!/usr/bin/env bash
set -e # Exit script immediately on first error.
set -x # Print commands and their arguments as they are executed.
/home/ubuntu/miniconda3/bin/conda create --name envmycondaenvironment python=3.5 # environment with python3.5
source activate envgatherurls
我从流浪汉那里收到以下错误
==> default: + source activate envmycondaenvironment
==> default: /tmp/vagrant-shell: line 21: activate: No such file or directory
为什么shell脚本找不到
activate
?我验证了/home/ubuntu/miniconda3/bin/
中可以找到activate
的已添加到.bashrc
文件的路径中 命令activate
由conda
提供,不会自动添加到PATH
环境变量中。请注意,bootstrap.sh
脚本作为root
运行,而不是vagrant
用户。因此,您需要确保root
用户的.bashrc
路径中有/home/ubuntu/miniconda3/bin
。如果我是你,我宁愿这样做:
#!/usr/bin/env bash
set -e # Exit script immediately on first error.
set -x # Print commands and their arguments as they are executed.
export PATH=/home/ubuntu/miniconda3/bin:$PATH
conda create --name envmycondaenvironment python=3.5 # environment with python3.5
source activate envgatherurls