Questions tagged [reticulate]

Usage questions regarding reticulate R package which provides a comprehensive set of tools for interoperability between Python and R.

Questions on the reticulate R package which provides a comprehensive set of tools for interopability between Python and R. More information on tutorials and API reference can be found on reticulate's website.

486 questions
3
votes
1 answer

scikit-learn in R with reticulate

I am trying to use the reticulate package in R. There is a good intro here, but I'm failing to make much progress. Let's say I want to do something simple like build a linear model with scikit-learn. (Yes, I know R can do this perfectly well, but…
Nick Criswell
  • 1,733
  • 2
  • 16
  • 32
3
votes
2 answers

How to get reticulate to access virtual environment

I have a pre-existing virtual environment set up for my python requirements, D:/SC/venv. I am trying to import data from a pickle into RStudio. I gather that in order to do so, I need to run a python script to read the pickle in RStudio using…
natedjurus
  • 319
  • 3
  • 11
3
votes
1 answer

install Python modules in Rstudio

I am trying to run python 3.8 in Rstudio using mac system. However, I am confused about installing modules using reticulate. When I install scipy using py_install("scipy"), I can install it successfully. However, when I test its availability, I got…
Wang
  • 1,314
  • 14
  • 21
3
votes
0 answers

RETICULATE: py_available returns FALSE

I created a virtual environment using conda. > library(reticulate) > use_condaenv("env_ret") > py_discover_config() python: C:\Program Files\Anaconda3\envs\env_ret\python.exe libpython: C:/Program…
Catarina
  • 53
  • 5
3
votes
1 answer

Define function in python chunk, then call it from R chunk

I want to define a function in Python, and then use that function in R code. I want to use Rmarkdown for this, so let's say my notebook looks like this: Let's define a Python function: ```{python} def concat(s1, s2): result = s1+s2 return…
Donentolon
  • 1,363
  • 1
  • 10
  • 17
3
votes
1 answer

Why is a dataframe from a dictionary behaving differently in R from a standalone dataframe via reticulate?

I am using reticulate from within R and attempting to convert a pandas dataframe from a dictionary, to an R dataframe, but I am finding that the conversion does not work and I'm not sure why? I want to be able to access the dataframe columns using…
CRWrangler
  • 33
  • 4
3
votes
0 answers

reticulate 1.13 -- "Error in sys$stdout$flush() : attempt to apply non-function" while using R (R-studio works)

reticulate (v1.13) returns error for each line while using R (3.5) However when same code(and same module) is run using R-Studio it works without errors. What could be the potential settings/configs to check/compare ? Need to have script run few…
3
votes
1 answer

How to pass convert string code of python to R using reticulate

I have function in python as following : def print_hello(): print("hello") Rather than writing to python file and reading it from file using source_python. I would like just pass function as string and convert into R. similar to following…
Kush Patel
  • 3,685
  • 5
  • 42
  • 65
3
votes
0 answers

R crashing with segfault when calling a function sourced with reticulate

I'm trying to write an R package with a function to send emails using python's smtplib module. The function works when I source it directly or with devtools::load_all(), but crashes R when I library my package and call the function. I was using the…
3
votes
3 answers

How to solve: "Error: object 'py' not found" in Rmarkdown when calling variable form python chunk to R chunk

I am using R markdown and reticulate package.After running a simple 2 line python code in a chunk,I cant use the python variable in the R chunk using the py$x function.I get the following error: "Error: object 'py' not found" I have already tried…
3
votes
0 answers

python shared library not found in R reticulate

I am having trouble getting the reticulate package in R to work. It cannot find the shared LIBPYTHON file it needs, no matter which version of Python I have loaded via module load, or which version I tell reticulate to use, directly within R. I'm…
Carmen Sandoval
  • 2,266
  • 5
  • 30
  • 46
3
votes
0 answers

Can not get python script running in R (Error in sys$stdout$flush() : attempt to apply non-function)

I'm trying to call a python script in R using library(reticulate), however I get the following error: sys$stdout$flush() : attempt to apply non-function I have python3 in my windows computer which is installed, using anaconda. I cannot run even a…
Raha
  • 113
  • 10
3
votes
1 answer

Using Python in R with reticulate package - Numpy not found

I am starting using reticulate package that allows using Python within R environment and wanted to perform mean-shift clustering with sklearn. So here's my attempt: > library(reticulate) > np <- import('numpy') > sklearn <- import('sklearn') >…
jakes
  • 1,964
  • 3
  • 18
  • 50
3
votes
1 answer

reticulate: Unable to configure python3

I'm using reticulate R package and want to configure python3 with it, however not able to do it. I tried the following code library(reticulate) packageVersion("reticulate") # [1] ‘1.10.0.9002’ use_python(python = "/usr/bin/python", required =…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
3
votes
1 answer

Read a parquet file in linux machine

I tried to read parquet file in python. I used parquet and json imports. I used the below code as I'm not looking to use pandas. with open("test.parquet") as fo: for row in parquet.DictReader(fo): print(json.dumps(row)) This seemed to…
naman1994
  • 315
  • 5
  • 11