线程这里关于 RODBC 已经过时了,大约 7 年前,他们的解决方案安装r-cran-odbc
后libiodbc2-dev
不起作用。从 R 3.5.1 开始,我得到了与 7 年前相同的错误
install.packages("RODBC", keep_outputs = T)
configure: error: "ODBC headers sql.h and sqlext.h not found"
ERROR: configuration failed for package ‘RODBC’
* removing ‘/opt/conda/lib/R/library/RODBC’
尽管已经安装了上述软件包。因此
如何在 R 3.5.1(R 和 Ubuntu 的最新版本)中在 Ubuntu 中安装 RODBC?
最小可复制基础(Dockerfile)
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG BASE_CONTAINER=jupyter/minimal-notebook
FROM $BASE_CONTAINER
LABEL maintainer="Jupyter Project <[email protected]>"
USER root
# R pre-requisites
RUN apt-get update && \
apt-get install -y --no-install-recommends \
fonts-dejavu \
tzdata \
libiodbc2-dev \
r-cran-rodbc \
gfortran \
gcc && \
rm -rf /var/lib/apt/lists/*
USER $NB_UID
# R packages
RUN conda install --quiet --yes \
'r-base=3.5.1' \
'r-irkernel=0.8*' \
'r-plyr=1.8*' \
'r-devtools=1.13*' \
'r-tidyverse=1.2*' \
'r-shiny=1.2*' \
'r-rmarkdown=1.11*' \
'r-forecast=8.2*' \
'r-rsqlite=2.1*' \
'r-reshape2=1.4*' \
'r-nycflights13=1.0*' \
'r-caret=6.0*' \
'r-rcurl=1.95*' \
'r-crayon=1.3*' \
'r-randomforest=4.6*' \
'r-htmltools=0.3*' \
'r-sparklyr=0.9*' \
'r-htmlwidgets=1.2*' \
'r-hexbin=1.27*' && \
conda clean -tipsy && \
fix-permissions $CONDA_DIR
以下软件包libiodbc2-dev
无法解决r-cran-rodbc
问题。
眼镜
$ uname -a
Linux 370485a13e40 4.9.93-linuxkit-aufs #1 SMP Wed Jun 6 16:55:56 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
sql.h 位于以下位置
$ apt-file sql.h
libdballe-dev: /usr/include/dballe/sql/sql.h
libiodbc2-dev: /usr/include/iodbc/sql.h
libmailutils-dev: /usr/include/mailutils/sql.h
libwine-dev: /usr/include/wine/windows/sql.h
libwine-development-dev: /usr/include/wine-development/wine/windows/sql.h
mingw-w64-common: /usr/share/mingw-w64/include/sql.h
mingw-w64-i686-dev: /usr/i686-w64-mingw32/include/sql.h
mingw-w64-x86-64-dev: /usr/x86_64-w64-mingw32/include/sql.h
pike7.8-core: /usr/lib/pike7.8/include/sql.h
pike8.0-core: /usr/lib/pike8.0/include/sql.h
unixodbc-dev: /usr/include/sql.h
和
# apt-file search /sqlext.h
libiodbc2-dev: /usr/include/iodbc/sqlext.h
libwine-dev: /usr/include/wine/windows/sqlext.h
libwine-development-dev: /usr/include/wine-development/wine/windows/sqlext.h
mingw-w64-common: /usr/share/mingw-w64/include/sqlext.h
mingw-w64-i686-dev: /usr/i686-w64-mingw32/include/sqlext.h
mingw-w64-x86-64-dev: /usr/x86_64-w64-mingw32/include/sqlext.h
unixodbc-dev: /usr/include/sqlext.h
答案1
可以通过从 conda 安装包来解决缺少标头的问题r-rodbc
,如下所示
RUN conda install --quiet --yes \
'r-base=3.5.1' \
'r-rodbc=1.3*' \
然后你就会得到以下错误
hecking for library containing SQLTables... no
configure: error: "no ODBC driver manager found"
ERROR: configuration failed for package ‘RODBC’
* removing ‘/opt/conda/lib/R/library/RODBC’
* restoring previous ‘/opt/conda/lib/R/library/RODBC’
你需要r-cran-odbc
,unixodbc
以及 apt 中的 'unixodbc-dev'(只有 unixodbc 是不够的),这样你的 Dockerfile 就变成了
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
ARG BASE_CONTAINER=jupyter/minimal-notebook
FROM $BASE_CONTAINER
LABEL maintainer="Jupyter Project <[email protected]>"
USER root
# R pre-requisites
RUN apt-get update && \
apt-get install -y --no-install-recommends \
fonts-dejavu \
tzdata \
unixodbc \
unixodbc-dev \
r-cran-rodbc \
gfortran \
gcc && \
rm -rf /var/lib/apt/lists/*
USER $NB_UID
# R packages
RUN conda install --quiet --yes \
'r-base=3.5.1' \
'r-rodbc=1.3*' \
'unixodbc=2.3.*' \
'r-irkernel=0.8*' \
'r-plyr=1.8*' \
'r-devtools=1.13*' \
'r-tidyverse=1.2*' \
'r-shiny=1.2*' \
'r-rmarkdown=1.11*' \
'r-forecast=8.2*' \
'r-rsqlite=2.1*' \
'r-reshape2=1.4*' \
'r-nycflights13=1.0*' \
'r-caret=6.0*' \
'r-rcurl=1.95*' \
'r-crayon=1.3*' \
'r-randomforest=4.6*' \
'r-htmltools=0.3*' \
'r-sparklyr=0.9*' \
'r-htmlwidgets=1.2*' \
'r-hexbin=1.27*' && \
conda clean -tipsy && \
fix-permissions $CONDA_DIR