使用rpy2加载R软件包时R内核崩溃 [英] R kernel crashes while loading R package using rpy2
问题描述
首先,我是rpy2/jupyter的新手,所以请不要判断我是否是问我问题的正确位置.
First of all, I’m new to rpy2 / jupyter so please don’t judge me if this isn’t the correct place to ask my question.
我正在尝试使用R和Python建立用于数据分析的集成工作流,但遇到以下错误:
I am trying to set up an integrated workflow for data analysis using R and Python and I encounter the following error:
我在Ubuntu 19.04上.使用Jupyter 1.0.0,Python 3.7.4,R 3.5.1,r-irkernel 1.0.2和rpy2 3.1.0运行conda环境,我通过R安装了R-package Seurat.
I am on Ubuntu 19.04. running a conda environment using Jupyter 1.0.0, Python 3.7.4, R 3.5.1, r-irkernel 1.0.2 and rpy2 3.1.0 and I installed the R-package Seurat through R.
当我使用R内核创建Jupyter笔记本时,可以很好地用library(Seurat)
加载Seurat.
When I create a Jupyter notebook using the R-kernel, I can load Seurat with library(Seurat)
just fine.
我也可以使用rpy2和rmagic在python中使用R代码:
I can also use R code in python using rpy2 and the rmagic such as:
%load_ext rpy2.ipython
%%R
data(allen, package = 'scRNAseq')
adata_allen <- as(allen, 'SingleCellExperiment')
但是,当我尝试使用rpy2加载Seurat时,内核崩溃:
However when I try to load Seurat using rpy2 the kernel crashes:
%%R
library(Seurat)
然后我收到以下消息:
内核重新启动
内核似乎已经死亡.它将自动重启
Kernel Restarting
The kernel appears to have died. It will restart automatically
Jupyter在命令行中给出以下消息:
Jupyter gives the following message in the command line:
[I 16:39:01.388 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
kernel 23284ec0-63d5-4b61-9ffa-b52d19851eab restarted
请注意,使用rpy2可以很好地加载其他库,例如library(dplyr)
.
Note that other libraries such as library(dplyr)
load just fine using rpy2.
My complete conda environment can be found in the attached text file.
我似乎无法找出导致问题的原因.有没有办法从Jupyter获取更详细的错误消息?
I just can’t seem to figure out what is causing the problem. Is there a way to get a more verbose error message from Jupyter?
非常感谢您的帮助!
关于Felix
推荐答案
R包Seurat
正在使用另一个名为reticulate
的R包,它提供了从R到Python的桥梁.
The R package Seurat
is using an other R package called reticulate
, providing a bridge to Python from R.
不幸的是,每当涉及到rpy2
和reticulate
时,R都会被初始化两次,这不可避免地导致了段错误.在撰写本文时,这仍然是一个开放的错误.在rpy2
侧的问题跟踪(可以在此处找到跟踪的reticulate
侧的链接):
Unfortunately, whenever rpy2
and reticulate
are involved R ends up being initialized twice, which results inevitably in a segfault. This is still an open bug at the time of writing. The issue tracking on the rpy2
side (a link to the reticulate
side of the tracking can be found there) is here:
https://bitbucket.org/rpy2 /rpy2/issues/456/reticulate-rpy2-sharing-r-process
这篇关于使用rpy2加载R软件包时R内核崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!