How to properly set the Python path for the reticulate package in OSX High Sierra?
See https://github.com/rstudio/reticulate/issues/45:
Do
library("reticulate")
use_python("/usr/bin/python", required = T)
Before anything else.
See also https://github.com/rstudio/reticulate/issues/227:
reticulate will always prefer a version of Python that includes NumPy to one that doesn't. Does the version at /usr/local/bin/python3 have NumPy?
Obviously, I have tried googling for the solution
Sometimes, googling only the function name "reticulate::use_python" helps.
How to change the default python version/path in Rstudio
OK, so I have posted too early - after some more googling I can solve this problem myself, but I think it is worth posting an answer here for people like me (i.e. not path-proficient or python-proficient).
There is something like a config file for R, called .Renviron. In order to access it, use Terminal to go to your home directory (i.e. the one that you go to when you type 'cd'). If you have never used this file before, it might not exist, in which case you need to create it.
Once in your home directory, type:
ls -a
then check on the list of files that appears whether .Renviron is there. Below are instructions what if you already have .Renviron (IF YES), and what if you don't (IF NO).
IF NO, type:
touch .Renviron
which creates the file.
IF YES, just proceed as below (without using the touch command).
Write:
nano .Renviron
the .Renviron file will open. In it, add a line that says:
RETICULATE_PYTHON="enter your desired path here"
so, in my case, this is:
RETICULATE_PYTHON="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3"
now save the file by exiting nano (ctrl+x) and clicking 'y' when it asks whether to save changes (press 'y' then press enter).
restart you RStudio. It should work now. I hope this is useful!
Using system-wide python via reticulate
The following fixes the problem:
Sys.setenv(RETICULATE_PYTHON = "/home/x/.virtualenvs/r.reticulate/bin/python")
library(reticulate)
Related Topics
Way to Securely Give a Password to R Application from the Terminal
Add (Subtract) Months Without Exceeding the Last Day of the New Month
Compile R Script into Standalone .Exe File
R Knitr: Possible to Programmatically Modify Chunk Labels
How to Add Multiple Columns to a Data.Frame in One Go
Determining Utm Zone (To Convert) from Longitude/Latitude
Make Frequency Histogram for Factor Variables
What Is the Significance of the New Reference Classes
Merging Two Columns into One in R
Check Whether Values in One Data Frame Column Exist in a Second Data Frame
Getting the Last N Elements of a Vector. Is There a Better Way Than Using the Length() Function
Merge Three Different Columns into a Date in R
How to Tell Cran to Install Package Dependencies Automatically
Write List of Data.Frames to Separate CSV Files with Lapply
Setting Defaults for Geoms and Scales Ggplot2
How to Produce Different Geom_Vline in Different Facets in R