【问题标题】:Error with %load_ext rpy2.ipython%load_ext rpy2.ipython 出错
【发布时间】:2015-06-13 14:44:46
【问题描述】:

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

我尝试使用 python 2.7.8 中的 rpy2。视窗 7 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

【问题讨论】:

    标签: python rpy2


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-02-06
      • 1970-01-01
      • 2018-02-08
      • 2016-04-27
      • 2012-10-26
      • 1970-01-01
      • 1970-01-01
      • 2021-08-20
      • 2016-03-19
      相关资源
      最近更新 更多