reticulate: unable to bind Python3 to rstudio-server on centos

Following the doc on providing hints to reticulate for finding & binding to Python3 on Centos. I have tried:

  1. Setting the environment variable RETICULATE_PYTHON to /opt/anaconda3/bin/python

  2. Setting the .Rprofile file in the user home directory as:
    Sys.setenv(RETICULATE_PYTHON = "/opt/anaconda3/bin/python")

  3. Restarting the Rsudio-Server

  4. Log in and tried executing:
    library("reticulate")
    use_python("/opt/anaconda3/python")
    use_virtualenv("Python3")

I have the virtualenv Python3 established. I can echo the RETICULATE_PYTHON environment variable in the IDE's terminal window. The .Rprofile file is shown in the IDE's Files tab.

The call to py_config() still returns Python2.7

How do I bind Python3 at /opt/anaconda3/bin/python as the target for the reticulate library with RStudio?

Thanks in advance,
Randy

Here is what I found.

It is a matter of order. If you make the R call to py_config first, and assuming you have the environment variable RETICULATE_PYTHON set, then you get the desired bind. I also used /etc/profile.d/rsudio.sh as the location for setting this environment variable as well as the location for the modifications anaconda makes into the installer's user's ~/.bashrc file.

That way, there is one location to manage rather than dealing with individual users' shell start-up locations.

library("reticulate")
     py_config()

then the desired bind occurs. See:

> library("reticulate")
> py_config()
python:         /opt/anaconda3/bin/python
libpython:      /opt/anaconda3/lib/libpython3.7m.so
pythonhome:     /opt/anaconda3:/opt/anaconda3
version:        3.7.2 (default, Dec 29 2018, 06:19:36)  [GCC 7.3.0]
numpy:          /opt/anaconda3/lib/python3.7/site-packages/numpy
numpy_version:  1.15.1

NOTE: Python version was forced by RETICULATE_PYTHON

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.