gpt4 book ai didi

r - 在Docker Plumber中使用R预测包

转载 作者:行者123 更新时间:2023-12-02 19:07:15 27 4
gpt4 key购买 nike

我正在尝试为使用预测库的R脚本构建docker镜像。我的Dockerfile看起来像这样:

    FROM r-base:latest

RUN mkdir -p /usr/local/src/myscripts
COPY ./Plumber.R /usr/local/src/myscripts
WORKDIR /usr/local/src/myscripts

RUN R -e 'install.packages("plumber")'
RUN R -e 'install.packages("forecast")'

EXPOSE 8000
ENTRYPOINT ["R", "-e", "pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8000)"]
CMD ["Plumber.R"]

Plumber.R非常简单,包含在第一行库中(预测)。
无需预测,一切都会很好,我可以运行容器。在上面的dockerfile和Plumber.R中添加预测时,容器的执行将停止:

During startup - Warning messages: 1: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called ‘forecast’ 2: package ‘forecast’ in options("defaultPackages") was not found pr <- plumber::plumb(commandArgs()[4]); pr$run(host='0.0.0.0', port=8000) Error in library(forecast) : there is no package called ‘forecast’ Calls: ... -> source -> withVisible -> eval -> eval -> library In addition: Warning message: In readLines(file) : incomplete final line found on 'Plumber.R' Execution halted



知道是什么问题吗?与所有其他软件包/库一起使用时,只有预测会造成麻烦。
提前谢谢了

最佳答案

当我使用Docker文件构建容器时,会收到一些消息:

Warning messages:
1: In install.packages("forecast") :
installation of package ‘curl’ had non-zero exit status
2: In install.packages("forecast") :
installation of package ‘TTR’ had non-zero exit status
3: In install.packages("forecast") :
installation of package ‘quantmod’ had non-zero exit status
4: In install.packages("forecast") :
installation of package ‘tseries’ had non-zero exit status
5: In install.packages("forecast") :
installation of package ‘forecast’ had non-zero exit status

这些消息的根源是以下错误:
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libcurl was not found. Try installing:
* deb: libcurl4-openssl-dev (Debian, Ubuntu, etc)
* rpm: libcurl-devel (Fedora, CentOS, RHEL)
* csw: libcurl_dev (Solaris)
If libcurl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libcurl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------

因此,在安装R软件包之前运行 apt-get install libcurl4-openssl-dev应该可以解决您的问题。

关于r - 在Docker Plumber中使用R预测包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48504153/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com