2016-07-25 68 views
0

以前,%R和%% R魔术师在IPython和Jupyter python笔记本中工作。 R端版本是:%魔法不再适用于IPython或Jupyter更新至Canopy版本1.7.4.3348

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" 
Copyright (C) 2016 The R Foundation for Statistical Computing 
Platform: x86_64-apple-darwin13.4.0 (64-bit) 

在Enthought篷,在笔记本电脑和IPython都升级到1.7.4.3348版本后不再工作。我曾尝试重新安装以下工作的Installing RKernelhttp://irkernel.github.io/installation/。我运行命令加载R-扩展作为每

%load_ext rpy2.ipython 

我得到的错误消息如下:

--------------------------------------------------------------------------- 
AttributeError       Traceback (most recent call last) 
<ipython-input-2-691c6d73b073> in <module>() 
----> 1 get_ipython().magic(u'load_ext rpy2.ipython') 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s) 
    2161   magic_name, _, magic_arg_s = arg_s.partition(' ') 
    2162   magic_name = magic_name.lstrip(prefilter.ESC_MAGIC) 
-> 2163   return self.run_line_magic(magic_name, magic_arg_s) 
    2164 
    2165  #------------------------------------------------------------------------- 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line) 
    2082     kwargs['local_ns'] = sys._getframe(stack_depth).f_locals 
    2083    with self.builtin_trap: 
-> 2084     result = fn(*args,**kwargs) 
    2085    return result 
    2086 

<decorator-gen-64> in load_ext(self, module_str) 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k) 
    191  # but it's overkill for just that one bit of state. 
    192  def magic_deco(arg): 
--> 193   call = lambda f, *a, **k: f(*a, **k) 
    194 
    195   if callable(arg): 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/magics/extension.pyc in load_ext(self, module_str) 
    64   if not module_str: 
    65    raise UsageError('Missing module name.') 
---> 66   res = self.shell.extension_manager.load_extension(module_str) 
    67 
    68   if res == 'already loaded': 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/extensions.pyc in load_extension(self, module_str) 
    82    if module_str not in sys.modules: 
    83     with prepended_to_syspath(self.ipython_extension_dir): 
---> 84      __import__(module_str) 
    85    mod = sys.modules[module_str] 
    86    if self._call_load_ipython_extension(mod): 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/rpy2/ipython/__init__.py in <module>() 
----> 1 from .rmagic import load_ipython_extension 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/rpy2/ipython/rmagic.py in <module>() 
    57 template_converter = ro.conversion.converter 
    58 try: 
---> 59  from rpy2.robjects import pandas2ri as baseconversion 
    60  template_converter = template_converter + baseconversion.converter 
    61 except ImportError: 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/rpy2/robjects/pandas2ri.py in <module>() 
     7        INTSXP) 
     8 
----> 9 from pandas.core.frame import DataFrame as PandasDataFrame 
    10 from pandas.core.series import Series as PandasSeries 
    11 from pandas.core.index import Index as PandasIndex 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/__init__.py in <module>() 
    20 
    21 # numpy compat 
---> 22 from pandas.compat.numpy_compat import * 
    23 
    24 try: 

/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/compat/numpy_compat.py in <module>() 
    13 
    14 # numpy versioning 
---> 15 _np_version = np.version.short_version 
    16 _np_version_under1p8 = LooseVersion(_np_version) < '1.8' 
    17 _np_version_under1p9 = LooseVersion(_np_version) < '1.9' 

AttributeError: 'module' object has no attribute 'version' 

难道是被列为1.10.4-有关numpy的冠层版本1和np。 版本结果是1.11.1(基于错误消息)?任何建议感激地收到。 PS。 R在控制台仍然工作,加上在终端和Jupyter与R内核...

+0

numpy 1.10.4和1.11.1都有'version'属性,所以我不认为这是问题所在。你能通过Canopy的帮助菜单提交一个错误报告,以便我们可以获得更多关于系统配置的信息吗? –

+0

完成,谢谢。我只是感到困惑,为什么它在其他地方工作,但不是在那个环境中。 –

回答

0

在Enthought的支持人员检查了numpy,然后熊猫的版本。重新安装都没有解决问题。不明原因的解决方案发生在Canopy终端上的pip install theano --upgrade命令中。将此错误记录为%R的一个未解释的问题,但强烈指示它是关于依赖项版本。