在IPython中运行rmagic的问题 - 优胜美地

时间:2014-10-20 01:29:19

标签: r ipython osx-yosemite

自从我升级到OSX Yosemite以来,我正在尝试将rmagic加载到IPython中。 我正在使用以下命令:

  

%load_ext rmagic

下面是我得到的错误,我不确定是不是因为我升级到优胜美地,或者因为我试图错误地加载R.我已经粘贴了所有Traceback以防有用,但错误以

结束
  

ImportError:无法导入名称转换

我的R版本是3.1.1 我的Python版本是2.7.6 我的IPython版本是2.3.0 不确定rpy2是什么版本,但我几天前才下载它所以我认为它是最新版本。

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

/Library/Python/2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   2203         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2204         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2205         return self.run_line_magic(magic_name, magic_arg_s)
   2206 
   2207     #-------------------------------------------------------------------------

/Library/Python/2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
   2124                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2125             with self.builtin_trap:
-> 2126                 result = fn(*args,**kwargs)
   2127             return result
   2128 

/Library/Python/2.7/site-packages/IPython/core/magics/extension.pyc in load_ext(self, module_str)

/Library/Python/2.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):

/Library/Python/2.7/site-packages/IPython/core/magics/extension.pyc in load_ext(self, module_str)
     61         if not module_str:
     62             raise UsageError('Missing module name.')
---> 63         res = self.shell.extension_manager.load_extension(module_str)
     64 
     65         if res == 'already loaded':

/Library/Python/2.7/site-packages/IPython/core/extensions.pyc in load_extension(self, module_str)
     96             if module_str not in sys.modules:
     97                 with prepended_to_syspath(self.ipython_extension_dir):
---> 98                     __import__(module_str)
     99             mod = sys.modules[module_str]
    100             if self._call_load_ipython_extension(mod):

/Library/Python/2.7/site-packages/rpy2/ipython/__init__.py in <module>()
----> 1 from .rmagic import load_ipython_extension

/Library/Python/2.7/site-packages/rpy2/ipython/rmagic.py in <module>()
     51 
     52 import rpy2.rinterface as ri
---> 53 import rpy2.robjects as ro
     54 import rpy2.robjects.packages as rpacks
     55 

/Library/Python/2.7/site-packages/rpy2/robjects/__init__.py in <module>()
     16 import rpy2.rlike.container as rlc
     17 
---> 18 from rpy2.robjects.robject import RObjectMixin, RObject
     19 from rpy2.robjects.vectors import *
     20 from rpy2.robjects.functions import Function, SignatureTranslatedFunction

/Library/Python/2.7/site-packages/rpy2/robjects/robject.py in <module>()
      5 rpy2.rinterface.initr()
      6 
----> 7 from . import conversion
      8 
      9 class RObjectMixin(object):

ImportError: cannot import name conversion

1 个答案:

答案 0 :(得分:1)

Minrk说得对 - 卸载并重新安装rpy2解决了我的问题。不知道为什么我之前没有想到这一点!感谢。