conda 安装 rpy2 版本不匹配问题解决方法

问题描述:Anaconda3(python 3.8) 安装 rpy2 (R 4.0.4)时尝试使用 conda install rpy2 安装,但是报错如下:

UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:

Specifications:

- rpy2 -> python[version='2.7.*|3.5.*|3.6.*|>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|3.4.*']

Your python: python=3.8 

If python is on the left-most side of the chain, that's the version you've asked for. When python appears to the right, that indicates that the thing on the left is somehow  not available for the python version you are constrained to. Note that conda will not change your python version to a different minor version unless you explicitly specify that.

 

解决办法:

1、下载 rpy2 之前,先确认在当前 python 和 R 版本下所支持的 rpy2 版本,版本查询路径如下:https://rpy2.github.io/doc.html

下拉查询对应的 rpy2 版本分别有 3.5.x,3.4.x 等,分别点击,以 3.5.x 为例点击进入,进入其 Background ,获取到其支持的 python 以及 R 版本为:

2、发现 rpy2 3.5.x 即满足需求,这里下载 3.5.1版本,方法如下:pip install rpy2==3.5.1

之后在 spyder(Python 3.8)调用 rpy2,import rpy2.robjects as robjects 可以顺利调用 !

 

 

 

 

 
posted @ 2023-03-16 18:36  史迪仔_lmj  Views(856)  Comments(0Edit  收藏  举报