python - %load_ext rpy2.ipython 错误

标签 python rpy2

刚刚开始使用 python,当我在 python 中遇到困难时希望能够使用 R。

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

最佳答案

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

关于python - %load_ext rpy2.ipython 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30819939/

相关文章:

Python在Excel内容中保存所需的行

python - 无法确定 R 库路径

python - 从 rpy2 传递给 R 的对象是什么?

python - Qt4,QMenu addAction,带参数的连接函数

python - 如何通过字符串访问 pytest fixture?

python - 使用 docker python "no space left on device"后无法正确重新启动 ubuntu,外围设备上没有可用内存

python - 参数组之间的互斥

python - 将命名列表向量从 R 转换为 Python 中的 rpy2?

linux - 如何使用默认 R 安装通过 conda 安装 rpy2

python - 特拉维斯 CI : error when installing rpy2