Hi,
I am trying to install the reticulate package into R. After typing install.packages("reticulate") in the R studio console, I get the following error message:
Warning in install.packages :
unable to access index for repository https://cran.rstudio.com/src/contrib:
cannot open URL 'https://cran.rstudio.com/src/contrib/PACKAGES'
Warning in install.packages :
package ‘reticulate’ is not available (for R version 3.5.0)
I am using R studio from within linux mint 18.2. It seems reticulate package is not supported for R versions 3.5.0? Any help to solve this would be most appreciated. Many thanks
For some reason, you did not reach the url. As a result, R tells you that reticulate is not available, but it is because it is not able to reach the cran url.
Are you in an online environment ? Are you behind some firewall or proxy ?
and that seems to install reticulate, although I am still having issues calling python. e.g. if I write a python script called add.py with the following code:
> library(reticulate)
>
> source_python('add.py')
Error in py_run_file_impl(file, local, convert) :
Unable to open file 'add.py' (does it exist?)
> add(5, 10)
Error in add(5, 10) : could not find function "add"
any ideas on what might be causing this will be most appreciated! thanks!
Right now, source_python() is looking inside your R working directory. If you're not sure what that is, you can find out with getwd(). You can change it with setwd(), but making a script dependent on doing so is kind of a kludge.
Where did you save add.py? Was it inside the working directory? If not, you can:
Move add.py to your working directory (even better if you are already working within an RStudio Project, where the working directory is project-specific)
Use a relative path to add.pythat works with your current working directory as the starting point
Use an absolute path
The first option is probably the best (maybe in conjunction with the here package), since it avoids introducing fragile, non-portable paths to your script. If you're anticipating a situation where you want to use python scripts that already live elsewhere, how to manage that gracefully is a much bigger question!