Getting Python/Reticulate working out of the box in Docker

I'm trying to get reticulate working out of the box, I frequently do work in docker, so I'd like to avoid installing miniconda every time. My docker file currently looks like:

FROM rocker/tidyverse

# Install R packages
RUN install2.r --error \
    rlang \
    devtools \
    reticulate

# UPDATE A SERIES OF PACKAGES
RUN apt-get update --fix-missing && apt-get install -y ca-certificates libglib2.0-0 libxext6 libsm6 libxrender1 libxml2-dev ack-grep

# INSTALL PYTHON 3 AND ANACONDA
RUN apt-get install -y python3-pip python3-dev && pip3 install virtualenv \
&& wget --quiet https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh -O ~/anaconda.sh \
&& /bin/bash ~/anaconda.sh -b -p /opt/conda && rm ~/anaconda.sh \
&& ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh \
&& echo ". /opt/conda/etc/profile.d/conda.sh" >> /home/rstudio/.bashrc

# WE EXPORT PATH FOR CONDA
ENV PATH="/opt/conda/bin:${PATH}"

# WRITE RETICULATE_PYTHON VARIABLE IN .Renviron
RUN echo "RETICULATE_PYTHON = '/opt/conda/bin/python3'" >> /usr/local/lib/R/etc/Renviron

Once I have built the docker image, and run a docker container, I create a notebook and insert a python chunk:

print([a for a in range(1,5)])

And get the error. any advice? Have I set RETICULATE_PYTHON correctly?

Screen Shot 2020-07-13 at 2.06.43 PM

non-chunks such as:

library(reticulate)
os <- import("os")
os$listdir(".")

works just fine.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.