ooominds / RSE-ticketing

Repository intended to be used as ticketing system for RSE support
0 stars 0 forks source link

Installing altair package for jupyterlab on sharc #5

Open kuchenrolle opened 6 years ago

kuchenrolle commented 6 years ago

I'm trying to install altair, a visualization library that is intended to be used with jupyterlab (successor of jupyter notebook). My installation fails at the last step, which is installing the vega3 extension that is required in order to render the graphics. The interactive session from which I'm trying to install it on sharc simply quits, I have no idea why.

The official installation instructions can be found here - installation via conda does not work as the release candidate is not available there (hence installation via pip) and jupyterlab 0.32 is also not released yet, so the plugin needs to be installed manually:

Steps to Reproduce

(on sharc; in an interactive session)


1. $ module load apps/python/anaconda3-4.2.0
2. $ source activate SomeEnvironment
3. $ pip install jupyterlab
4. $ pip install altair==2.0.0rc1
5. $ conda install nodejs
6. $ jupyter labextension install @jupyterlab/vega3-extension 

(6 fails, session quits)

Expected Behaviour

The installation should run through and the example from the official installation instructions should result in the rendered output.

On my local machine, the steps above run through perfectly and the library works as desired.

Your Environment

willfurnass commented 6 years ago

Hi @kuchenrolle. Apologies that no-one's got back to you about this yet. I've also been keen to have a play with altair.

I think for now it is probably simplest if we stick to trying to get altair working with the traditional Jupyter Notebook interface rather than JupyterLab: I haven't yet looked into upgrading the JupyterHub setup on ShARC so it supports JupyterLab.

I haven't got Altair working with Jupyter Notebooks on ShARC yet but have investigated a few options (notes, primarily for my own benefit, can be found below). I can continue looking into this but it won't be before next Weds (2018-04-18). If we're lucky the 2.0.0 release candidate will have been superseded by the proper 2.0.0 release by then.


Here's what I've tried based in part on these instructions:

qrshx
module load apps/python/conda

# Create and activate a simple environment containing just python 3.6 + dependencies 
conda create -y -n altair-test python=3.6
. activate altair-test

# Install numpy and pandas from conda (if required) as that way we get numpy built against the MKL (we would not if installing using pip)
conda install -y pandas numpy # install using conda and not pip so built against the MKL

# Install a recent 'notebook' package from conda-forge:
conda config --append channels conda-forge # Add conda-forge as lowest priority channel; needed for recent 'notebook' version
conda install -y notebook==5.4.1

# Install release candidate of altair 2.0.0
pip install altair==2.0.0rc1  # to get the 2.0 release candidate as not yet available from conda-forge

# Install vega3 package - required if going to use altair from a Jupyter Notebook
pip install vega3

# jupyter nbextension install --sys-prefix --py vega3 --> not needed as notebook version >= 5.3

# NB need to add `alt.renderers.enable('notebook')` if want to use Altair from a Jupyter Notebook

This all installs fine but when I try to run the example from the Altair+Jupyter Notebook installation instructions:

import altair as alt
from vega_datasets import data

# for the notebook only (not for JupyterLab) run this command once per session
alt.renderers.enable('notebook')

iris = data.iris()

alt.Chart(iris).mark_point().encode(
    x='petalLength',
    y='petalWidth',
    color='species'
)

... only a text representation of the plots is rendered.

I then tried explicitly enabling the vega3 nbextension (even though the altair install instructions said it wasn't needed if notebook>=5.3) but that didn't help.

I then noticed that the Javascript console complained that:

Could not cross validate the widget frontend and backend versions

and backtraces made reference to jupyter-js-widgets, which I think may be related to the ipywidgets package. I tried installing ipywidgets then installed and enabled the widgetsnbextension Javascript library:

$ pip install ipywidgets
$ jupyter nbextension install widgetsnbextension --py --sys-prefix
$ jupyter nbextension enable widgetsnbextension --py --sys-prefix

but that didn't help either.

kuchenrolle commented 6 years ago

Hey Will,

when I first came across altair, I tried installing it for Jupyter Notebook, but also failed to get it to actually plot anything, rather than just display the text representation. With Jupyter Lab it worked right out of the box and since Jupyter Lab seems strictly better than regular Notebooks, I decided to switch immediately.

For the moment, I don't need it to work on JupyterHub, X11-forwarding is fast enough that I can just use an interactive session to work on the server with Jupyter Lab. So all my needs would be met if I could just install that labextension. (:

willfurnass commented 6 years ago

@kuchenrolle Now that I'm officially part of the team do you want me to continue to investigate this?