<p>You're using an outdated version of R. You can use the R 4.0 from <code>conda-forge</code> channel, just create an environment with <code>r-base</code> and then install <code>rpy2</code>, the latest version compatible with R 4.0 is available through <code>pip</code></p>
<pre><code>conda create -n rpy2 -c conda-forge r-base
conda activate rpy2
pip install rpy2
</code></pre>
<p>Now you can use rpy2 with R 4.0 in your python code.</p>
<pre><code>import rpy2.robjects as robjects
robjects.r('install.packages(&quot;BiocManager&quot;, '
           'repos=&quot;http://cran.r-project.org&quot;)')
robjects.r('BiocManager::install(&quot;seqLogo&quot;)')
robjects.r('library(seqLogo)')
</code></pre>
<p>Remember deactivate your env with <code>conda deactivate</code>.</p>

CC BY-SA 4.0
2020-08-28T19:00:41.133Z
Thank you so much this work! but when I do the same thing for "GenomicAlignments" package I get error:    
    raise embedded.RRuntimeError(_rinterface._geterrmessage())
rpy2.rinterface_lib.embedded.RRuntimeError: Error in (new("nonstandardGenericFunction", .Data = function (expr, envir = parent.frame(),  : 
  object 'GenomicAlignments' not found
aBiologist
CC BY-SA 4.0
2020-08-30T23:04:30.933Z
I can't replicate you error. I did `robjects.r('BiocManager::install("GenomicAlignments")')` and then `robjects.r('library(GenomicAlignments)')` and it works.
zorbax
CC BY-SA 4.0
2022-10-27T14:53:58.867Z
I am unable to do this for pcalg (https://cran.r-project.org/web/packages/pcalg/pcalg.pdf). Can I see a minimal working example?
S_S
CC BY-SA 4.0
2020-08-28T11:23:51.950Z
2020-08-28T11:23:51.950Z
zorbax
<p>I am running into an error when I tried to run the following lines of code, the <code>error</code> at line 3:</p>
<pre><code>1 from rpy2.robjects.packages import importr
2 base = importr('base')
3 base.source(&quot;http://www.bioconductor.org/biocLite.R&quot;)
4 biocinstaller = importr(&quot;BiocInstaller&quot;)
5 biocinstaller.biocLite(&quot;seqLogo&quot;)
</code></pre>
<p><code>rpy2.rinterface_lib.embedded.RRuntimeError: Error: With R version 3.5 or greater, install Bioconductor packages using BiocManager; see https://bioconductor.org/install</code></p>
<p>How can I use <code>BiocManager</code> installer instead of <code>biocLite </code> and reflect that on my code? I couldn't find any documentation or source that talk about this error from within Python.</p>
<p>Thank you in advance</p>

CC BY-SA 4.0
2020-08-28T10:44:04.960Z
you need upgrade your R base version.
zorbax
CC BY-SA 4.0
2020-08-28T12:59:43.053Z
Definitely recommend installation via Conda as @zorbax points out. This normal stuff for installing rpy2 As a word of warning further errors with rpy2 are also normal and as a general rule of thumb rpy2 is a nightmare. For R's ggplot2 via rpy2 is outdated and will not import the full funcationality of the ggplot2 into Python3. This is irregular given have important ggplot2 is as a graphing package. After my experience I would use subprocessing into R rather than deal with rpy2 again
M__
<r><python><rpy2>
Error When Using biocLite as an installer in rpy2 python library
# Error When Using biocLite as an installer in rpy2 python library

(Asked by: username_0 on 2020-08-28)

I am running into an error when I tried to run the following lines of code, the error at line 3:
1 from rpy2.robjects.packages import importr
2 base = importr('base')
3 base.source("http://www.bioconductor.org/biocLite.R")
4 biocinstaller = importr("BiocInstaller")
5 biocinstaller.biocLite("seqLogo")

rpy2.rinterface_lib.embedded.RRuntimeError: Error: With R version 3.5 or greater, install Bioconductor packages using BiocManager; see https://bioconductor.org/install
How can I use BiocManager installer instead of biocLite  and reflect that on my code? I couldn't find any documentation or source that talk about this error from within Python.
Thank you in advance

**Tags:** r, python, rpy2
> **Comments:**
> **username_1**: you need upgrade your R base version.  
> **username_2**: Definitely recommend installation via Conda as @zorbax points out. This normal stuff for installing rpy2 As a word of warning further errors with rpy2 are also normal and as a general rule of thumb rpy2 is a nightmare. For R's ggplot2 via rpy2 is outdated and will not import the full funcationality of the ggplot2 into Python3. This is irregular given have important ggplot2 is as a graphing package. After my experience I would use subprocessing into R rather than deal with rpy2 again  

---

## 1 answers

### Answer by username_1 on 2020-08-28. Score: 2

You're using an outdated version of R. You can use the R 4.0 from conda-forge channel, just create an environment with r-base and then install rpy2, the latest version compatible with R 4.0 is available through pip
conda create -n rpy2 -c conda-forge r-base
conda activate rpy2
pip install rpy2

Now you can use rpy2 with R 4.0 in your python code.
import rpy2.robjects as robjects
robjects.r('install.packages("BiocManager", '
           'repos="http://cran.r-project.org")')
robjects.r('BiocManager::install("seqLogo")')
robjects.r('library(seqLogo)')

Remember deactivate your env with conda deactivate.

> **Comments:**
> **username_0**: Thank you so much this work! but when I do the same thing for "GenomicAlignments" package I get error:         raise embedded.RRuntimeError(_rinterface._geterrmessage()) rpy2.rinterface_lib.embedded.RRuntimeError: Error in (new("nonstandardGenericFunction", .Data = function (expr, envir = parent.frame(),  :    object 'GenomicAlignments' not found  
> **username_1**: I can't replicate you error. I did `robjects.r('BiocManager::install("GenomicAlignments")')` and then `robjects.r('library(GenomicAlignments)')` and it works.  
> **username_3**: I am unable to do this for pcalg (https://cran.r-project.org/web/packages/pcalg/pcalg.pdf). Can I see a minimal working example?  

---

