在rocker/tidyverse:3.3.2
内,即使我没有错误地安装r-cran-rjava
r-cran-nloptr
,R中也缺少软件包rJAva
和nloptr
。为什么?? >
请参阅下面的Docker文件:
FROM rocker/tidyverse:3.3.2
RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
RUN apt-get -y update && apt-get install -y \
default-jdk r-cran-rjava r-cran-nloptr libssh2-1-dev
RUN R -e "library('rJava')" # Error in library("rJava") : there is no package called ‘rJava’
RUN R -e "library('nloptr')" # Error in library("nloptr") : there is no package called nloptr
谢谢
答案 0 :(得分:4)
这是因为您正在安装为R的最新稳定版本准备的程序包二进制文件,但您已安装的R是较旧的版本,而未安装要使用的R版本的程序包。
答案 1 :(得分:0)
这是解决方案:
FROM openjdk:7-slim-jessie
RUN apt-get update
RUN apt-get install -y curl
RUN printf "deb http://deb.debian.org/debian jessie main\ndeb-src http://deb.debian.org/debian jessie main\ndeb http://security.debian.org/debian-security jessie/updates main\ndeb-src http://security.debian.org/debian-security jessie/updates main\n" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bash-completion \
ca-certificates \
file \
fonts-texgyre \
g++ \
gfortran \
gsfonts \
libblas-dev \
libbz2-1.0 \
libcurl3 \
libicu52 \
libjpeg62-turbo \
libopenblas-dev \
libpangocairo-1.0-0 \
libpcre3 \
libpng12-0 \
libtiff5 \
liblzma5 \
locales \
make \
unzip \
zip \
zlib1g \
&& echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen en_US.utf8 \
&& /usr/sbin/update-locale LANG=en_US.UTF-8
RUN BUILDDEPS="curl \
# default-jdk \
libbz2-dev \
libcairo2-dev \
libcurl4-openssl-dev \
libpango1.0-dev \
libjpeg-dev \
libicu-dev \
libpcre3-dev \
libpng-dev \
libreadline-dev \
libtiff5-dev \
liblzma-dev \
libx11-dev \
libxt-dev \
perl \
tcl8.5-dev \
tk8.5-dev \
texinfo \
texlive-extra-utils \
texlive-fonts-recommended \
texlive-fonts-extra \
texlive-latex-recommended \
x11proto-core-dev \
xauth \
xfonts-base \
xvfb \
zlib1g-dev" \
&& apt-get install -y --no-install-recommends $BUILDDEPS
RUN cd tmp/ \
## Download source code
&& curl -O https://cran.r-project.org/src/base/R-3/R-3.2.3.tar.gz \
## Extract source code
&& tar -xf R-3.2.3.tar.gz \
&& cd R-3.2.3 \
## Set compiler flags
&& R_PAPERSIZE=letter \
R_BATCHSAVE="--no-save --no-restore" \
R_BROWSER=xdg-open \
PAGER=/usr/bin/pager \
PERL=/usr/bin/perl \
R_UNZIPCMD=/usr/bin/unzip \
R_ZIPCMD=/usr/bin/zip \
R_PRINTCMD=/usr/bin/lpr \
LIBnn=lib \
AWK=/usr/bin/awk \
CFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g" \
CXXFLAGS="-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g" \
## Configure options
./configure --enable-R-shlib \
--enable-memory-profiling \
--with-readline \
--with-blas \
--with-tcltk \
--disable-nls \
--with-recommended-packages \
## Build and install
&& make \
&& make install
## Add a default CRAN mirror
RUN echo "options(repos = c(CRAN = 'https://cran.rstudio.com/'), download.file.method = 'libcurl')" >> /usr/local/lib/R/etc/Rprofile.site \
## Add a library directory (for user-installed packages)
&& mkdir -p /usr/local/lib/R/site-library \
&& chown root:staff /usr/local/lib/R/site-library \
&& chmod g+wx /usr/local/lib/R/site-library \
## Fix library path
&& echo "R_LIBS_USER='/usr/local/lib/R/site-library'" >> /usr/local/lib/R/etc/Renviron \
&& echo "R_LIBS=\${R_LIBS-'/usr/local/lib/R/site-library:/usr/local/lib/R/library:/usr/lib/R/library'}" >> /usr/local/lib/R/etc/Renviron \
## install packages from date-locked MRAN snapshot of CRAN
&& [ -z "$BUILD_DATE" ] && BUILD_DATE=$(TZ="America/Los_Angeles" date -I) || true \
&& MRAN=https://mran.microsoft.com/snapshot/${BUILD_DATE} \
&& echo MRAN=$MRAN >> /etc/environment \
&& export MRAN=$MRAN \
&& echo "options(repos = c(CRAN='$MRAN'), download.file.method = 'libcurl')" >> /usr/local/lib/R/etc/Rprofile.site \
## Use littler installation scripts
&& Rscript -e "install.packages(c('littler', 'docopt'), repo = '$MRAN')" \
&& ln -s /usr/local/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \
&& ln -s /usr/local/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \
&& ln -s /usr/local/lib/R/site-library/littler/bin/r /usr/local/bin/r \
## Clean up from R source install
&& cd / \
&& rm -rf /tmp/* \
&& apt-get remove --purge -y $BUILDDEPS \
&& apt-get autoremove -y \
&& apt-get autoclean -y \
&& rm -rf /var/lib/apt/lists/*
RUN echo "options(repos = c(CRAN='https://mran.microsoft.com/snapshot/2016-10-10'), download.file.method = 'libcurl')" >> /usr/local/lib/R/etc/Rprofile.site
RUN printf "deb http://snapshot.debian.org/archive/debian/20161010T101527Z/ jessie main\ndeb-src http://snapshot.debian.org/archive/debian/20161010T101527Z/ jessie main\ndeb http://snapshot.debian.org/archive/debian/20161010T101527Z/ jessie-backports main\ndeb-src http://snapshot.debian.org/archive/debian/20161010T101527Z/ jessie-backports main\n" > /etc/apt/sources.list
#RUN apt-get -y -o Acquire::Check-Valid-Until=false update && apt-get install -y \
# r-cran-rjava r-cran-nloptr libssh2-1-dev
RUN apt-get -y -o Acquire::Check-Valid-Until=false update
RUN printf "deb http://deb.debian.org/debian jessie main\ndeb-src http://deb.debian.org/debian jessie main\ndeb http://security.debian.org/debian-security jessie/updates main\ndeb-src http://security.debian.org/debian-security jessie/updates main\n" > /etc/apt/sources.list
RUN apt-get -y -o Acquire::Check-Valid-Until=false update
RUN apt-get install -y libxml2-dev
#RUN apt-get install -y r-cran-xml2
#RUN apt-get install -y r-base-dev
RUN apt-get install -y libbz2-dev libicu-dev liblzma-dev
#RUN echo "install.packages('rJava', repos='http://www.rforge.net/', configure.args='--disable-Xrs')" | R --no-save
RUN apt-get install -y libnlopt-dev libnlopt-guile0 libnlopt0
RUN R -e "install.packages('xml2')"
RUN R -e "install.packages('rJava')"
RUN R -e "install.packages('xml2')"
RUN R -e "install.packages('ReporteRs')"
RUN R -e "install.packages('nloptr')"