在 Google Cloud Platform 上的 Jupyter Notebook 中安装 RPostgres 库

问题描述

我正在尝试在 R 中安装 RPostgres 库,但我在 Google Cloud Platform 上使用 JupyterLab。我在 github.com/r-dbi/RPostgres 上找到了一些建议,但没有一个包含使用 Google Cloud Notebooks 时的信息。

即使在将包放入 JupyterLab 上的正确文件夹后尝试从源代码安装包后,我仍然收到 RPostgres 具有“非零退出状态”的错误:

install.packages("MyPath/RPostgres_1.3.3.tar.gz",repos=NULL,type='source')

我收到同样的错误消息 RPostgres 有“非零退出状态”。谢谢。

解决方法

要解决此问题,您首先需要安装“libpq-dev”,因为这是 SO answer 的先决条件。请按照以下步骤将其应用于 Google Cloud Notebook。

  • 在 JupyterLab 中打开一个终端并执行 sudo apt-get install libpq-dev

    enter image description here

  • 打开一个 R 笔记本,使用 install.packages("RPostgres")

    安装 Rpostgres

    enter image description here

  • 运行 library() 并检查它是否安装正确

    enter image description here

请注意,我用于测试的机器是在 AI Platform -> Notebooks -> R instance 中创建的。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...