我在 jupyter 中创建了一个名为“rpy2”的新环境并尝试使用%%R
魔法,但安装失败。
QN:如何在 jupyter-notebook 中使用 %%R 魔法?
平台:MacOS High Sierra
脚步
jupyter kernelspec list
conda create -n rpy2 python=3.7
source activate rpy2
which pip
/Users/poudel/miniconda3/envs/rpy2/bin/pip install rpy2
conda install ipykernel
python -m ipykernel install --user --name rpy2 --display-name "Py37rpy2"
jupyter-notebook
问题
# Now
import rpy2 shows no error
import rpy2.rinterface # gives error
笔记
# I have checked all the files given in error log, all of them exist
492 ls /Users/poudel/miniconda3/lib/R/lib/libR.dylib
493 ls /usr/lib/libiconv.2.dylib
494 ls /Users/poudel/miniconda3/lib/R/lib/libR.dylib
495 /Users/poudel/miniconda3/lib/R/lib/libR.dylib
496 ls /Users/poudel/miniconda3/lib/R/lib/libR.dylib
All shows given file, and none is missing.
错误
OSError:无法加载库'/Users/poudel/miniconda3/lib/R/lib/libR.dylib':dlopen(/Users/poudel/miniconda3/lib/R/lib/libR.dylib,2):找不到符号: _libiconv 引用自:/Users/poudel/miniconda3/lib/R/lib/libR.dylib 预期于:/Users/poudel/miniconda3/lib/R/lib/libR.dylib 中的 /usr/lib/libiconv.2.dylib
更新
正如@akrun 所建议的,我尝试使用pyper
,但加载库需要无限时间,并且停止时显示它已损坏管道。
pip install pyper
.