%load_ext rpy2.ipython 错误

Error with %load_ext rpy2.ipython

刚开始 python,当我遇到 python 中的某些问题时,希望能够使用 R。

我正在尝试使用 python 2.7.8 中的 rpy2。 Windows7 64 位。 我将 ipython 和 运行 中的这个用于以下错误。

我有点困惑,因为它说我没有 ipython 模块(来自 ipython 笔记本)。

我在解释回溯时也遇到了问题。它是否说我应该安装 "module_str"?

无论如何感谢您的帮助!

伯纳德

import rpy2
%load_ext rpy2.ipython
    ​
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-e00003b513dd> in <module>()
      1 import rpy2
----> 2 get_ipython().magic(u'load_ext rpy2.ipython')

C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.pyc in magic(self,     arg_s)
   2302         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2303         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2304         return self.run_line_magic(magic_name, magic_arg_s)
   2305 
   2306     #-------------------------------------------------------------------    ------

C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.pyc in     run_line_magic(self, magic_name, line)
   2223                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2224             with self.builtin_trap:
-> 2225                 result = fn(*args,**kwargs)
   2226             return result
   2227 

C:\Anaconda\lib\site-packages\IPython\core\magics\extension.pyc in     load_ext(self, module_str)

C:\Anaconda\lib\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):

C:\Anaconda\lib\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':

C:\Anaconda\lib\site-packages\IPython\core\extensions.pyc in                 load_extension(self, module_str)
     83             if module_str not in sys.modules:
     84                 with prepended_to_syspath(self.ipython_extension_dir):
---> 85                     __import__(module_str)
     86             mod = sys.modules[module_str]
         87             if self._call_load_ipython_extension(mod):

ImportError: No module named ipython

您正在尝试使用比您安装的 rpy2 版本更新的功能。