Search code examples
dockerjupyter-notebookipythonrpy2

install %%R cell magic in docker from jupyter docker stack


I tried installing the datascience jupyter docker image (tag 45b8529a6bfc, last update Feb 14, 2019) from docker stacks. My entire dockerfile:

FROM jupyter/datascience-notebook:45b8529a6bfc
USER $NB_UID

When I open a new Jupyter notebook with an R kernel, the notebook works fine. When I try a %%R cell magic in an ipython notebook, it doesn't work:

%%R
3+4
UsageError: Cell magic `%%R` not found.

I wandered around various stackoverflow answers and internet searches, tried installing rpy2 (it was already installed). Didn't work.

Suggestions?


Solution

  • I tried %load_ext rpy2.ipython as suggested by @lgautier, and got the error message No module named 'simplegeneric'. Once I pip installed simplegeneric, everything works and I don't need the load_ext statement.

    Not sure why the dockerfile doesn't install simplegeneric, but there you have it.