【问题标题】:Installing rpy2 with Docker is unable to find R path使用 Docker 安装 rpy2 找不到 R 路径
【发布时间】:2017-03-30 13:49:18
【问题描述】:

使用 Docker 的 Django 应用程序需要安装 rpy2 作为依赖项。虽然我安装了 r-base 容器并将其指定为依赖项,但在安装 django 要求时我不断收到:

Collecting rpy2==2.8.3 (from -r /requirements/base.txt (line 55))
  Downloading rpy2-2.8.3.tar.gz (186kB)
    Complete output from command python setup.py egg_info:
    Error: Tried to guess R's HOME but no command 'R' in the PATH.

如何在 Docker 内部指定 R 路径在哪里?

我的 server.yml 看起来像这样:

version: '2'
services:

  r:
    build: ./services/r

  django:
    build:
      context: ./myproject/
      dockerfile: ./compose/django/Dockerfile
    env_file:
      - .env
      - .env-server
    environment:
      - DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_USER}
    depends_on:
      - postgres
      - r
    command: /gunicorn.sh
    volumes:
      - ./myproject:/app

django 的 Dockerfile 是:

FROM python:2.7
ENV PYTHONUNBUFFERED 1

COPY ./requirements /requirements

RUN pip install -r /requirements/production.txt \
    && pip install -r /requirements/test.txt \
    && groupadd -r django \
    && useradd -r -g django django

COPY . /app
RUN chown -R django /app

COPY ./compose/django/gunicorn.sh /gunicorn.sh
COPY ./compose/django/entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r//' /entrypoint.sh \
    && sed -i 's/\r//' /gunicorn.sh \
    && chmod +x /entrypoint.sh \
    && chown django /entrypoint.sh \
    && chmod +x /gunicorn.sh \
    && chown django /gunicorn.sh

WORKDIR /app

ENTRYPOINT ["/entrypoint.sh"]

R 的 Dockerfile 是:

FROM r-base

【问题讨论】:

    标签: r django docker dockerfile rpy2


    【解决方案1】:

    在 django 容器中安装 r 更容易。因此,删除 r 容器并修改 django docker 文件添加以下行,工作:

    RUN apt-get --force-yes update \
        && apt-get --assume-yes install r-base-core
    

    【讨论】:

      猜你喜欢
      • 2021-07-05
      • 2015-06-25
      • 2016-01-04
      • 2015-09-04
      • 2016-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-10
      相关资源
      最近更新 更多