Hi this is my first stackoverflow question so sorry in advance for any mistakes. I am trying to start playing with R reticulate
library. I have installed the package, and tried to import os
Python module. Everything seemed to be ok, but then while I start typing for example os$listdir
R throws this error: Error in py_module_import(module, convert = convert) : ModuleNotFoundError: No module named 'rpytools'
. Here is my entire code:
install.packages("reticulate")
library(reticulate)
os <- import("os")
os$listdir("")
Here is my output of py_config()
:
python: C:\PROGRA~3\ANACON~1\python.exe
libpython: C:/PROGRA~3/ANACON~1/python36.dll
pythonhome: C:\PROGRA~3\ANACON~1
version: 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)]
Architecture: 64bit
numpy: C:\PROGRA~3\ANACON~1\lib\site-packages\numpy
numpy_version: 1.12.1
os: C:\PROGRA~3\ANACON~1\lib\os.py
and py_available(TRUE)
returns TRUE
...
Please write me if there is any additional info needed.
The short answer is you need to use RStudio version 1.2 or higher, currently only available as a preview release, to get experimental
reticulate
support.Support for
reticulate
in current RStudio stable releases (<1.2) is pretty flaky and any hope of using RStudio <1.2 as a Python IDE falls apart as soon as you try to work with imported modules. This is mentioned as an offhand comment in thereticulate
docs:Your code doesn't throw an error in RStudio 1.2: