rpy2 import is not working

后端 未结 8 1153
逝去的感伤
逝去的感伤 2021-02-14 16:16

I get an error when I try to import rpy2. Here is the code and error.

>>> import pandas.rpy.common
Traceback (most recent call last):  

File \"C:\\PF\         


        
相关标签:
8条回答
  • 2021-02-14 16:17

    In my case it initially did not wor installing it with conda. I solved it by first changing the active environment.

    source activate [environment Name]
    conda install -c r rpy2=2.8.5
    
    0 讨论(0)
  • 2021-02-14 16:22

    That looks like a pandas interface to rpy2. Separately, you also need rpy2 installed on your system. I don't have rpy2, so it was easy for me to check this:

    In [1]: import pandas.rpy.common
    (...)
    ImportError: No module named rpy2.robjects.packages
    
    
    In [2]: import rpy2
    (...)
    ImportError: No module named rpy2
    

    I installed it using pip:

    $ pip install rpy2
    
    In [1]: import pandas.rpy.common
    

    It works! It import rpy2 works for you, but import pandas.rpy.common does not then the problem might be more subtle.

    0 讨论(0)
  • 2021-02-14 16:32

    I recently ran into a similar issue. I was trying to install rpy2 using anaconda version of python(3.6.3). Below, mentioned command worked for me,

    * python3 -m conda install rpy2
    
    0 讨论(0)
  • 2021-02-14 16:32

    I installed using, conda install -m rpy2

    and moved the directory of rpy2 from rpy2-2.9.1-py3.6-win-amd64.egg folder to the path from where the packages are called during the import and then it worked.

    0 讨论(0)
  • 2021-02-14 16:33

    Well, first you have to install rpy2. If you are using conda you can do it using the following command

    conda install -c r rpy2 
    

    Then, if you want to use R on Jupyter Notebook environment you can activate R using

    %load_ext rpy2.ipython
    
    0 讨论(0)
  • 2021-02-14 16:34

    RPy2 is a separate project from Pandas (homepage here), so you'll have to install it separately. You should be able to do pip install rpy2, then restart Python and try again.

    0 讨论(0)
提交回复
热议问题