python - 如何在 colab.research 上安装 rpy2?

标签 python r

如何在 colab.research.google 上安装 rpy2?我尝试了以下命令:

pip install rpy2 
import rpy2

但它不起作用。这是得到的错误:

Collecting rpy2
Using cached https://files.pythonhosted.org/packages/02/d1/074ffbbe7b4bf74c60b75d74c8e67a1e4515b0d85f85cd6540e39610754a/rpy2-2.9.5.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-je87ula0/rpy2/

---------------------------------------------------------------------------

ModuleNotFoundError                       Traceback (most recent call last)

<ipython-input-15-93ecdf466471> in <module>()
  1 get_ipython().system('pip install rpy2')
----> 2 import rpy2

ModuleNotFoundError: No module named 'rpy2'

预先感谢您的帮助, 伊内斯。

最佳答案

编写 !pip install rpy2 而不是 pip install rpy2

编辑

根据rpy2的文档可以找到here :

Running Rpy2 will require compiled libraries for R, Python, and readline; building rpy2 will require the corresponding development headers (check the documentation for more information about building rpy2).

所以,这应该有效

!apt-get install r-base
!pip install rpy2

关于python - 如何在 colab.research 上安装 rpy2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54371616/

相关文章:

python - 如何使用 Python Popen 压缩 mysqldump

r - 为现有数据表 R 的每一行创建一个新数据表,同时避免内存向量问题

r - 在函数中包含库调用?

r - 使用 `chisq.test()$p.value` 为多个组获取 `dplyr::group_by()`

python - 通过字典调用类方法

python - 您如何模拟 PyMySQL 的返回值以在 Python 中进行测试?

python - 如何在我的 python 应用程序中保护我的 AWS 访问 ID 和 key

python - 将 cURL 命令转换为 Python 请求命令

R:将 CrossTable 导出到 Latex

r - 是否有一个包或函数可以对向量的模式/类型/类做出合理的猜测?