Nextjournal / Feb 23 2021 / Latest

Environment Builder - Python

This article builds the default environment for Python cells, as well as a comparable Python 2 env.

1.
Python 3

Download and install conda, add its library directory so ldconfig will pick it up, and ensure pip is up to date.

CONDA_VER="4.5.4"

curl -sSL -o ~/anaconda.sh \
    https://repo.continuum.io/miniconda/Miniconda3-${CONDA_VER}-Linux-x86_64.sh
/bin/bash ~/anaconda.sh -b -p /opt/conda
rm ~/anaconda.sh

echo "/opt/conda/lib" >> /etc/ld.so.conf.d/conda.conf

pip install --upgrade pip

This default image has support for matplotlib and plotly. We'll also install setuptools to make any additional installs less annoying.

conda install --yes --channel anaconda --channel conda-forge \
  plotly matplotlib setuptools

ldconfig

Check that it works.

python --version

2.
Python 2

Download and install conda, set up ld, update pip.

CONDA_VER="4.5.4"

curl -sSL -o ~/anaconda.sh \
    https://repo.continuum.io/miniconda/Miniconda2-${CONDA_VER}-Linux-x86_64.sh
/bin/bash ~/anaconda.sh -b -p /opt/conda
rm ~/anaconda.sh

echo "/opt/conda/lib" >> /etc/ld.so.conf.d/conda.conf

pip install --upgrade pip

Install matplotlib, plotly, setuptools.

conda install --yes --channel anaconda --channel conda-forge \
  plotly matplotlib setuptools

ldconfig

Check Python is installed.

python --version