【问题标题】:Can you use rmagic (rpy2) in google colaboratory?你可以在 google colaboratory 中使用 rmagic (rpy2) 吗?
【发布时间】:2018-07-21 17:18:52
【问题描述】:

我知道 google colaboratory 还不支持 R 内核。 rmagic呢?我可以使用rpy2吗?

我试过了:

!pip install rpy2==2.8.6

得到了:

Collecting rpy2==2.8.6
  Using cached https://files.pythonhosted.org/packages/32/54/d102eec14f9cabd0df60682a38bd45c36169a1ec8fb8a690bf436cb6d758/rpy2-2.8.6.tar.gz
    Complete output from command python setup.py egg_info:
    Error: Tried to guess R's HOME but no command 'R' in the PATH.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-3bSiiD/rpy2/

我猜它不起作用,因为 R 没有安装在运行此笔记本的任何云计算机上,并且可能无法安装它。但我希望我错了,有人可能知道解决方法。

【问题讨论】:

    标签: google-colaboratory


    【解决方案1】:

    好的,我回答了我自己的问题。我以为这肯定会失败,但还是尝试了:

    !apt-get update
    !apt-get install r-base
    !pip install rpy2==2.8.6
    

    它成功了!

    【讨论】:

    • 如果您现在想使用 rpy2,我建议您使用最新版本(在撰写本文时是 2.9.4)。
    • 谢谢,@lgautier。我相信 2.9.x 之后的 rpy2 只支持 python 3。我需要 python 2.7,但这对于其他使用 python 3 的人来说是一个很好的提示。
    • @kmartin 您能否添加更多示例代码来展示您如何继续使用 rpy2?例如,你做了 %load_ext rpy2.ipython 吗? (现在不适合我)谢谢!
    猜你喜欢
    • 2018-04-29
    • 2018-07-08
    • 2023-03-12
    • 2020-01-29
    • 2016-12-01
    • 2010-09-23
    • 1970-01-01
    • 2014-11-13
    • 1970-01-01
    相关资源
    最近更新 更多