让%R magic在Ipython笔记本上运行时遇到问题。
执行以下命令
%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
答案 0 :(得分:0)
您是否尝试在启动笔记本之前在cmd窗口中键入命令activate root
?
答案 1 :(得分:0)
尝试:
$ conda install -c r r-essentials
然后:
$ conda install -c r rpy2
考虑使用conda
而不是pip
安装对此上下文的任何依赖。