The first lines I run when launching my rstudio session are:
library(reticulate)
use_python("/usr/local/lib/python3.6/site-packages")
However, when I run py_config()
it shows as still using the default python 2.7 installation.
This is an issue b.c I'm unable to import any modules that were installed for python3. Any idea why this isn't working? I followed documentation fairly closely.
I observed that neither the technique "use_python('path')" nor the tactic of Sys.setenv(RETICULATE_PYTHON = 'path') in .RProfile worked for me (of course I am sure it must have worked for others.)
In any case the line at terminal,
did produce two paths to choose from (one for python2 and one for python3 installed on my mac), so then I was able to create a ".Renviron" file in my home directory with this single line in it:
After I restarted RStudio,
library(reticulate)
activates the desired python3, andrepl_python()
opens a python3 interactive window, etc. etc.use_python("path/to/python3")
definitely does not work, although the Reticulate Python version configuration article says so. Don't believe it! :-)I have tried to set the interpreter with the current Reticulate version (1.13), and the package gave me a very honest answer:
Luckily, putting a
.Renviron
file containing the lineRETICULATE_PYTHON="/path/to/python3"
into the user's home directory does work:Finally, here comes the added value of my answer:
You can configure the Reticulate Python interpreter for all users by adding the
RETICULATE_PYTHON
line to the globalRenviron
file. It is usually found in theetc
subdirectory of R's home directory. You can find out where R's home is by running theR.home()
function in the R interpreter. In my case (Ubuntu 18.04.3 LTS) it was/usr/lib/R
, so I edited/usr/lib/R/etc/Renviron
. You obviously need admin rights to do this.The only thing that work for me on Mac OSX, perform the following commands in the terminal:
Then open it, I use vim, so my command is then the following:
Add the following (for anaconda):
Otherwise, in the terminal type:
which python3
and enter your output pathIt worked for me:
It seems important that you set RETICULATE_PYTHON before you first use reticulate.