【问题标题】:%load_ext rpy2.ipython doesn't work - module not found (OS: linux mint 17 | R 3.1.2 | python 2.7.6 | ipython notebook 2.3.1 | rpy2 2.5.2)%load_ext rpy2.ipython 不起作用 - 找不到模块(操作系统:linux mint 17 | R 3.1.2 | python 2.7.6 | ipython notebook 2.3.1 | rpy2 2.5.2)
【发布时间】:2014-11-28 19:58:58
【问题描述】:

在 Ipython notebook 上使用 %R 魔法时遇到问题。

执行以下命令

%load_ext rpy2.ipython

导致'ImportError: No moduled named ipython':

  ---------------------------------------------------------------------------
 ImportError                               Traceback (most recent call last)
 <ipython-input-18-691c6d73b073> in <module>()
 ----> 1 get_ipython().magic(u'load_ext rpy2.ipython')
 
 /usr/local/lib/python2.7/dist-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     #-------------------------------------------------------------------------
 
 /usr/local/lib/python2.7/dist-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 
 
 /usr/local/lib/python2.7/dist-packages/IPython/core/magics/extension.pyc in load_ext(self, module_str)
 
 /usr/local/lib/python2.7/dist-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):
 
 /usr/local/lib/python2.7/dist-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':
 
 /usr/local/lib/python2.7/dist-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):
 
 ImportError: No module named ipython

任何线索可能是什么问题?

谢谢


编辑:2016 年 6 月 1 日

导入语句也丢失了

导入 rpy2.ipython

%load_ext rpy2.ipython

【问题讨论】:

  • 您确定安装了 rpy2 2.5.2 吗?这可能发生在 ipython 正在获取旧版本的 rpy2。
  • 很确定,这就是我运行 help(rpy2) 时所说的。将在星期一再试一次。
  • 感谢 Igautier,您在这里提供了解决方案:pip install singledispatch

标签: ipython-notebook rpy2


【解决方案1】:

试试:

$ conda install -c r r-essentials

然后:

$ conda install -c r rpy2

考虑使用 conda 而不是 pip 安装对此上下文的任何依赖项。

【讨论】:

    【解决方案2】:

    您是否尝试在启动笔记本之前在 cmd 窗口中输入命令 activate root

    【讨论】:

    • 现在可以使用了。特别是当由 anaconda 管理时。早在 2014 年,存储库还没有建立/经常更新。
    猜你喜欢
    • 1970-01-01
    • 2016-04-27
    • 1970-01-01
    • 2018-02-08
    • 2017-02-06
    • 1970-01-01
    • 2014-07-17
    • 2021-02-06
    • 1970-01-01
    相关资源
    最近更新 更多