繁体   English   中英

Vagrant安装Anaconda Python?

[英]Vagrant Installing Anaconda Python?

Anaconda python是通过bash脚本安装的(在linux中)。 我正在尝试使用Vagrant配置来安装Anacaonda Python。

在bash脚本中(遵循文档bootstrap.sh示例 )我有一个bootstrap.sh脚本:

  1. wget安装脚本
  2. chmod +x使其可执行
  3. ./<script>.sh进行安装。

安装此方法失败,因为安装有一些提示,其中一个需要非默认答案。

是否可以通过bash脚本自动化安装? 如果没有,是否有必要使用像Puppet这样的东西? 我根本不认识Puppet,所以试图避免使用......也许是时候挖掘了?

最终目标是发布Vagrant文​​件而不是托管Vagrant框。

PS我最初的,微弱的尝试使用了linux yes命令,但必须存在更好的方法!

在你的bootstrap.sh中只包含以下内容:

miniconda=Miniconda3-3.7.4-Linux-x86_64.sh
cd /vagrant
if [[ ! -f $miniconda ]]; then
    wget --quiet http://repo.continuum.io/miniconda/$miniconda
fi
chmod +x $miniconda
./$miniconda -b -p /opt/anaconda

cat >> /home/vagrant/.bashrc << END
# add for anaconda install
PATH=/opt/anaconda/bin:\$PATH
END

-b选项以批处理模式运行,是您正在寻找的:

>>>> ./Miniconda-3.7.0-Linux-x86_64.sh -h 
usage: ./Miniconda-3.7.0-Linux-x86_64.sh [options]

Installs Miniconda 3.7.0

    -b           run install in batch mode (without manual intervention),
                 it is expected the license terms are agreed upon
    -f           no error if install prefix already exists
    -h           print this help message and exit
    -p PREFIX    install prefix, defaults to /Users/phil/miniconda

我通常也会将Miniconda(或其链接)直接放在bootstrap.sh所在的“ vagrant ”中。 这样,您不会在每个流浪者期间(在初始化或销毁之后)从网上下载。

我根据Phil Cooper的回答创建了一个GitHub存储库。

https://github.com/tomohiro1221/vagrant-anaconda

对于想要通过刮刀开始使用anaconda的新盒子的人来说,可以通过使用来自continuumio的anaconda3盒子(或其他anaconda盒子)来实现。 通过使用以下命令来初始化流浪者。

vagrant init continuumio/anaconda3; vagrant up --provider virtualbox

这里还有其他几个conda和miniconda盒子 这种方法很容易实现,但是如果你想将conda添加到现有的盒子中,那么Phil Cooper的解决方案就是你的选择。

Puppet不会让这项任务变得更容易,因为运行交互式脚本不是其核心功能的一部分(我甚至不相信它可以通过第三方模块获得)。

通过使用expect工具,确实存在更好的方法。 它允许您编写一个健壮的脚本来与安装过程的输入提示进行交互。

这是一个expect脚本文件,用于在Vagrant上安装Anaconda(Anaconda-2.0.1-Linux-x86_64.sh):

#!/usr/bin/expect
#exp_internal 1
set timeout 600
spawn /tmp/Anaconda-2.0.1-Linux-x86_64.sh
send "\r"
send " "
send " "
send " "
send " "
send " "
expect -exact "\[no\] >>>"
send "yes\r"
expect -exact "\[/home/vagrant/anaconda\] >>>"
send "\r"
expect -exact "\[no\] >>>"
send "yes\r"

取消注释exp_internal 1以查看匹配超时是否为Anaconda的安装时间,在我的盒子上花了390秒。

编辑:我实际上在这里完成了与Anaconda一起工作的Vagrant环境: https//github.com/colour-science/colour-vagrant

您可以使用ContinuumIO的官方流浪图像中所需的图像

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM