1

I use Anaconda Jupyter notebook via VSCode or directly via browser. I installed rpy2 via conda as:

conda install -c r r-essentials rpy2 --yes

Then in a Python cell of Jupyter Notebook, I ran:

%load_ext rpy2.ipython

And got

R[write to console]: Error in gettext(fmt, domain = domain, trim = trim) : 
  3 arguments passed to .Internal(gettext) which requires 2

Details

I use Windows 10. I have a separate R installation on my computer too.

In ipynb, the same error appears if I run:

import rpy2.robjects as robjects

More details on the error:

%load_ext rpy2.ipython
R[write to console]: Error in gettext(fmt, domain = domain, trim = trim) : 
  3 arguments passed to .Internal(gettext) which requires 2

Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
RRuntimeError                             Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_18052\1837600852.py in <cell line: 1>()
----> 1 get_ipython().run_line_magic('load_ext', 'rpy2.ipython')

c:\Users\user\anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
   2415                 kwargs['local_ns'] = self.get_local_scope(stack_depth)
   2416             with self.builtin_trap:
-> 2417                 result = fn(*args, **kwargs)
   2418             return result
   2419 

c:\Users\user\anaconda3\lib\site-packages\decorator.py in fun(*args, **kw)
    230             if not kwsyntax:
    231                 args, kw = fix(args, kw, sig)
--> 232             return caller(func, *(extras + args), **kw)
    233     fun.__name__ = func.__name__
    234     fun.__doc__ = func.__doc__

c:\Users\user\anaconda3\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k)
    185     # but it's overkill for just that one bit of state.
    186     def magic_deco(arg):
--> 187         call = lambda f, *a, **k: f(*a, **k)
    188 
    189         if callable(arg):
...
    812 

RRuntimeError: Error in gettext(fmt, domain = domain, trim = trim) : 
  3 arguments passed to .Internal(gettext) which requires 2

Other things I tried:

# Works:
import rpy2
print(rpy2.__version__)
# Returns: 
3.5.1
import rpy2.situation
for row in rpy2.situation.iter_info():
   print(row)
# Returns:
rpy2 version:
3.5.1
Python version:
3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:50:36) [MSC v.1929 64 bit (AMD64)]
Looking for R's HOME:
    Environment variable R_HOME: None
    InstallPath in the registry: C:\Program Files\R\R-4.2.2
    Environment variable R_USER: None
    Environment variable R_LIBS_USER: None
Unable to determine R library path: Command '('C:\\Users\\user\\anaconda3\\lib\\R\\bin\\Rscript', '-e', 'cat(Sys.getenv("LD_LIBRARY_PATH"))')' returned non-zero exit status 1.
R version:
    In the PATH: R version 4.1.3 (2022-03-10) -- "One Push-Up"
    Loading R library from rpy2: OK
Additional directories to load R packages from:
None
C extension compilation:
  include:
  ['C:/PROGRA~1/R/R-4.2.2/include', 'C:/PROGRA~1/R/R-4.2.2/include/x64']
  libraries:
  ['R', 'm']
  library_dirs:
  ['C:/PROGRA~1/R/R-4.2.2/bin/x64']
  extra_compile_args:
  []
  extra_link_args:
  []

A similar issue with no answer is here.

Might be related but is related to continuous integration: https://github.com/rpy2/rpy2/issues/874

GegznaV
  • 4,938
  • 4
  • 23
  • 43

0 Answers0