Anaconda

Install prerequistes.

sudo yum install -y bzip2


Change directory to /tmp.

cd /tmp


Fetch the install script.

curl -O https://repo.anaconda.com/archive/Anaconda3-5.3.1-Linux-x86_64.sh


Make the script executable.

sudo chmod +x ./Anaconda3-5.3.1-Linux-x86_64.sh


Execute the script.

sudo ./Anaconda3-5.3.1-Linux-x86_64.sh


Make the installation location system-wide.   When prompted,   select /opt/anaconda3.

Anaconda3 will now be installed into this location:
/root/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/root/anaconda3] >>> /opt/anaconda3


Follow the prompts and specify the installation location:

Do you wish the installer to initialize Anaconda3
in your /root/.bashrc ? [yes|no],
[no] >>> no


Instead,   create a system-wide Anaconda profile in the /etc/profile.d directory.

sudo vi /etc/profile.d/conda.sh 


Ensure you have the correct path.

### !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/opt/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/opt/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
### <<< conda init <<<


Execute the shell script.

source /etc/profile.d/conda.sh


Perform conda update.

sudo /opt/anaconda3/bin/conda update conda


Verify installation.

python --version


Returns.

Python 3.7.2


R

Add the epel-release repository.

sudo yum install -y epel-release


Install R.

sudo yum install R


Verify R installation

R --version

Returns:

R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
https://www.gnu.org/licenses/.


Install R packages in a single go as an R script.

# ipak function: install and load multiple R packages.


ipak <- function(pkg){
    new.pkg <- pkg[!(pkg %in% installed.packages()[, "Package"])]
    if (length(new.pkg)) 
        install.packages(new.pkg, dependencies = TRUE)
    sapply(pkg, require, character.only = TRUE)
}

# usage
packages <- c("ggplot2", "plyr", "reshape2", "RColorBrewer", "scales", "grid", "reticulate")
ipak(packages)


Jupyter Notebook

Azure offers a free upyter notebook service described here.   Here we build a custom notebook with kernels for R,   Python,   and SAS.

Open port 8888.

az vm open-port --priority 1002 --resource-group Py4SAS --name Py4SAS-vm --port 8888


Launch the notebook.

jupyter notebook --no-browser --port 8888 --ip=0.0.0.0 --notebook-dir=$HOME/notebook

Returns:

[I 19:01:25.207 NotebookApp] JupyterLab extension loaded from /opt/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 19:01:25.207 NotebookApp] JupyterLab application directory is /opt/anaconda3/share/jupyter/lab
[I 19:01:25.220 NotebookApp] Serving notebooks from local directory: /home/trb/notebook
[I 19:01:25.220 NotebookApp] The Jupyter Notebook is running at:
[I 19:01:25.220 NotebookApp] http://(Py4SAS-vm or 127.0.0.1):8888/?token=15e2ea208a9d458654616c30835d01a40eda2b892f3a2d5a
[I 19:01:25.220 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 19:01:25.221 NotebookApp]

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://(Py4SAS-vm or 127.0.0.1):8888/?token=15e2ea208a9d458654616c30835d01a40eda2b892f3a2d5a


Return notebook server and token.

jupyter notebook list

Returns:

Currently running servers:
http://0.0.0.0:8888/?token=15e2ea208a9d458654616c30835d01a40eda2b892f3a2d5a :: /home/trb/notebook


R Notebook kernel

Use the conda package manager.

conda install -c r r-irkernel 


Make the irkernel package available for R.

IRkernel::installspec(name = 'ir33', displayname = 'R 3.6 on AZ')


Launch the notebook.

jupyter notebook --no-browser --port 8888 --ip=0.0.0.0 --notebook-dir=$HOME/notebook


Cover Art


R Studio Server

R Studio Server is a popular U/I for R.

wget https://download2.rstudio.org/server/centos6/x86_64/rstudio-server-rhel-1.2.1335-x86_64.rpm


Install R Studio Server.

sudo yum install rstudio-server-rhel-1.2.1335-x86_64.rpm


Open port 8787.

az vm open-port --priority 1008 --resource-group Py4SAS --name Py4SAS-vm --port 8787


Launch the server.

http://<server-ip>:8787


Cover Art


SAS Notebook kernel

The SAS kernel has dependencies on SASPy.   See the section on this site for installing and configuring SASPy on Azure.

pip install --upgrade pip


Install the sas-kernel.

pip install sas_kernel


Verify the kernels availability.

jupyter kernelspec list

Returns.

Available kernels:
  sas        /home/trb/.local/share/jupyter/kernels/sas
  python3    /opt/anaconda3/share/jupyter/kernels/python3


With the SAS kernel installed, start a new notebook session.

Cover Art