0

I am trying to incorporate some R code in the python environment. I imported rpy2 package successfully. However, I get the error when I try to import rpy2.objects

from rpy2.robjects import pandas2ri

I get the below error

Error in glue(.Internal(R.home()), "library", "base", "R", "base", sep = 
.Platform$file.sep) : 
  4 arguments passed to .Internal(paste) which requires 3
Error: could not find function "attach"
Error: object '.ArgsEnv' not found
Fatal error: unable to initialize the JIT
Restarting kernel... 

I found some of the related questions in SE here here and here. But, none of them seem to work.

botloggy
  • 179
  • 1
  • 11

1 Answers1

0

Form what I've gathered: if you have R installed on your machine it will avtomatically use the system's installation of R instead of the version rpy2 requires. To omit that I just added

import os
os.environ['R_HOME'] = '/Users/<your user>/anaconda3/envs/<env name>/lib/R'

before I imported anything from rpy2. If it doesn't work, you may have to uninstall R from your machine completely.