【发布时间】: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