Error with %load_ext rpy2.ipython

2.2k views Asked by At

Just started python, and would like to be able to use R when I'm stuck on something in python.

I trying to use rpy2 from python 2.7.8. Windows 7 64bit. I using this from ipython and run into the following error.

I'm a bit confused because it says I don't have the ipython module (from an ipython notebook).

I'm also having trouble interpreting the traceback. Does it says that I should install "module_str"?

Anyway thanks for the help!

Bernard

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
1

There are 1 answers

0
lgautier On BEST ANSWER

You are trying to use a feature that is more recent than the version of rpy2 you have installed.