我刚刚通过conda-forge安装了rpy2,当我在jupyter笔记本中使用它时,出现以下错误
---------------------------------------------------------------------------
LookupError Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\rpy2\robjects\__init__.py in __getattribute__(self, attr)
325 try:
--> 326 return self.__getitem__(attr)
327 except LookupError as le:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\rpy2\robjects\__init__.py in __getitem__(self, item)
330 def __getitem__(self, item):
--> 331 res = _globalenv.get(item)
332 res = conversion.ri2py(res)
LookupError: 'png' not found
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
<ipython-input-3-c9dc5af3c1ce> in <module>()
----> 1 get_ipython().run_line_magic('R', '2+2')
~\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2129 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2130 with self.builtin_trap:
-> 2131 result = fn(*args,**kwargs)
2132 return result
2133
<decorator-gen-130> in R(self, line, cell, local_ns)
~\AppData\Local\Continuum\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):
~\AppData\Local\Continuum\anaconda3\lib\site-packages\rpy2\ipython\rmagic.py in R(self, line, cell, local_ns)
685 ro.r.assign(input, val)
686
--> 687 tmpd = self.setup_graphics(args)
688
689 text_output = ''
~\AppData\Local\Continuum\anaconda3\lib\site-packages\rpy2\ipython\rmagic.py in setup_graphics(self, args)
422 if self.device == 'png':
423 # Note: that %% is to pass into R for interpolation there
--> 424 ro.r.png("%s/Rplots%%03d.png" % tmpd_fix_slashes,
425 **argdict)
426 elif self.device == 'svg':
~\AppData\Local\Continuum\anaconda3\lib\site-packages\rpy2\robjects\__init__.py in __getattribute__(self, attr)
326 return self.__getitem__(attr)
327 except LookupError as le:
--> 328 raise AttributeError(orig_ae)
329
330 def __getitem__(self, item):
AttributeError: 'R' object has no attribute 'png'
我试图重新安装rpy2并查看了Internet,但找不到任何解决方案,有人遇到过此问题吗?
我正在运行Windows 7,并在Jupyter中用
加载了程序包%load_ext rpy2.ipython
非常感谢您的帮助:)
答案 0 :(得分:0)
R可能是在没有PNG支持的情况下编译的。如今,这可能并不常见,但我想R魔术应该能抓住它。
现在在https://bitbucket.org/rpy2/rpy2/issues/476/catching-missing-png-capabilities-in-r中跟踪