Vagrant Install Anaconda Python?

Anaconda python is installed (on Linux) through a bash script. I am trying to use the Vagrant setup to install Anacaonda Python.

In a bash script (following the documentation of the bootstrap.sh example ), I have a bootstrap.sh script that:

  • wget install script
  • chmod +x to make it doable
  • ./<script>.sh to install.

Installation of this method fails because the installation has several prompts, one of which requires a non-default response.

Is it possible to automate the installation using a bash script? If not, should I use something like Puppet? I don’t know Puppets at all, so I tried to avoid using ... maybe it's time to delve into?

The ultimate goal is to send the Vagrantfile and not place the Vagrant box.

PS My initial, weak attempts used the linux yes command, but a better way must exist!

+6
source share
6 answers

In your bootstrap.sh, just include something like:

 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 

The -b works in batch mode and is what you are looking for:

 >>>> ./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 

I also usually put Miniconda (or a link to it) directly in the " vagrant " where bootstrap.sh is located. Thus, you do not download from the Internet during each tramp (after init or destroy).

+14
source
+3
source

For people who want to create a new box with an anaconda from scrach, it can be achieved using the anaconda3 box (or other anaconda boxes) from continuumio. Using the following command for init vagrant.

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

There are several other conda and miniconda containers here . This approach is easy to achieve, however, if you want to add conda to an existing box, then Phil Cooper's solution is the way to go.

+2
source

Puppet will not make this task easier, because running interactive scripts is not part of its core functions (I don’t even think that it is available through third-party modules).

A better way exists using the expect tool. This allows you to write a reliable script to interact with input requests from the installation process.

0
source

Here is the expect script file for installing Anaconda (Anaconda-2.0.1-Linux-x86_64.sh) on Vagrant:

 #!/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" 

Uncomment exp_internal 1 , to see the latency for the Anaconda installation time, took 390 seconds in my box.

Edit: I actually ended up working with Tramps with Anaconda here: https://github.com/colour-science/colour-vagrant

0
source

You can use your desired image from official branded images from ContinuumIO

0
source

Source: https://habr.com/ru/post/973853/


All Articles