下面的代码没有在 docker 中安装一些包 (tidyverse", "odbc")。运行 dockerfile 时它没有显示错误,但之后运行 DAG(运行我的 r 脚本),它显示了一个错误说找不到包 (tidyverse", "odbc").
这是为什么? 'http://cran.rstudio.com' 应该包含“tidyverse”和“odbc”。
FROM apache/airflow:1.10.12-python3.8
USER root
RUN apt update -y && apt install -y vim
RUN pip install --upgrade pip
RUN apt-get install -y r-base
RUN echo "r <- getOption('repos'); r['CRAN'] <- 'http://cran.rstudio.com'; options(repos = r);" > ~/.Rprofile
RUN Rscript -e "install.packages('DBI')"
RUN Rscript -e "install.packages('data.table')"
RUN Rscript -e "install.packages('dplyr')"
RUN Rscript -e "install.packages('dbplyr')"
RUN Rscript -e "install.packages('magrittr')"
RUN Rscript -e "install.packages('furrr')"
RUN Rscript -e "install.packages('lubridate')"
RUN Rscript -e "install.packages('future')"
RUN Rscript -e "install.packages('jsonlite')"
RUN Rscript -e "install.packages('odbc')"
RUN Rscript -e "install.packages('tidyverse')"
USER airflow
# Copy files
COPY . ./
# Install dependencies
RUN pip install -r requirements.txt
# Python path
ENV PYTHONPATH "${PYTHONPATH}:/opt/airflow"
RUN airflow initdb
当我在处理一些包时,R.file 可以很简单:
library("dplyr")
library("tidyverse")
print("text")
在 DAG 中运行 R.file 后的错误:
INFO - Error in library("tidyverse") : there is no package called ‘tidyverse’.
所以有“dplyr”,但没有“tidyverse”。
A