Setting the environment variable RETICULATE_PYTHON to /opt/anaconda3/bin/python
Setting the .Rprofile file in the user home directory as:
Sys.setenv(RETICULATE_PYTHON = "/opt/anaconda3/bin/python")
Restarting the Rsudio-Server
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?
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