NASA-Openscapes / py-rocket

Rocker (R Docker stack) via Jupyter lab
MIT License
2 stars 1 forks source link

Set `RETICULATE_PYTHON` to support better use of Python from RStudio #1

Open yuvipanda opened 11 months ago

yuvipanda commented 11 months ago

Currently, trying to use Reticulate to access python from RStudio is a bit of a mess. See this thread on the openscapes slack (https://openscapes.slack.com/archives/C02NC3Y62J1/p1696449495538389) for examples.

Setting RETICULATE_PYTHON env var to (the fully expanded version of) ${CONDA_PREFIX}/bin/python will actually solve almost all these issues for users of this image. There are upstream fixes that @cboettig has graciously offered to bring up with reticulate, but we don't have to wait on those getting fixed.

We should:

  1. Set this as an ENV directive so it is picked up by jupyter and terminals in jupyter
  2. Put this inside ${R_HOME}/etc/Renviron.site so it's picked up by RStudio (which doesn't pick up env vars the regular way). The existing file should be apended to, not clobbered. I think on this image R_HOME is /usr/local/lib/R. It won't have CONDA_PREFIX set so the fully expanded path should be set.
eeholmes commented 9 months ago

To be explicit, add this to the Dockerfile

echo "PATH=${PATH}" >>"${R_HOME}/etc/Renviron.site"