首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么rpy2包在码头建造阶段出现错误?

为什么rpy2包在码头建造阶段出现错误?
EN

Stack Overflow用户
提问于 2022-07-13 06:31:29
回答 1查看 87关注 0票数 0

我正在尝试构建一个Docker容器,它应该是bookworm并运行python 3.9。默认情况下,bookworm默认安装python 3.10。我必须使用bookworm,因为它是生产的要求。

问题是NumPy与它不兼容。所以我不得不使用python 3.9。现在,我得到了一个错误,无法从rpy2安装requirements.txt包。

我的码头档案

代码语言:javascript
复制
FROM debian:bookworm-20210816-slim


COPY ./requirements.txt /mmm/requirements.txt

WORKDIR /mmm
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get install curl -y


RUN apt-get install -y libgit2-dev
RUN apt install -y r-cran-remotes
RUN apt-get -y install r-base

RUN apt-get install python3.9 -y
RUN apt-get install python3.9-distutils -y
RUN apt-get install python3.9-apt -y
RUN apt-get install wget -y

RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
RUN python3.9 get-pip.py
RUN pip --version
RUN pip3 --version

RUN apt-get install -y libnlopt-dev
RUN apt-get -y install gcc
RUN python3.9 -c 'print("Hi")'

RUN pip3 install --no-cache-dir flask pipupgrade
RUN pip3 install --upgrade pip setuptools
RUN apt-get install gfortran
RUN apt-get -y update
RUN apt-get install --no-install-recommends software-properties-common dirmngr -y
RUN wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
RUN add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
RUN apt-get install --no-install-recommends r-base

RUN R -e "update.packages(repos='http://cran.rstudio.com/', ask=FALSE, checkBuilt=TRUE)"
RUN R -e "install.packages('remotes',dependencies=TRUE)"
RUN R -e "require(remotes)"
RUN R -e "remotes::install_version('minqa')"
RUN R -e "remotes::install_version('RcppEigen')"
RUN R -e "remotes::install_version('nloptr')"
RUN R -e "remotes::install_version('lme4')"
RUN R -e "remotes::install_version('pbkrtest')"
RUN R -e "remotes::install_version('lmerTest')"
RUN R -e "install.packages('lmerTest',dependencies=TRUE)"
RUN pip3 install pandas
RUN pip3 install scipy
RUN pip3 install ray
RUN pip3 install --no-cache-dir -r requirements.txt
ENV SSO "ENABLE"


COPY . /mmm

EXPOSE 8086

CMD ["python3.9", "manage.py", "run"]

我的Requirements.txt文件

代码语言:javascript
复制
rpy2
Werkzeug
nltk
Flask_Script
pytest
numba
pymongo
statsmodels
Flask_MonitoringDashboard
pingouin
flasgger
cryptography
Flask_RESTful
Flask_Cors
marshmallow
config_with_yaml
Flask
boto3
requests
fastapi
PyJWT
scikit_learn
pytz
markupsafe
itsdangerous
pysftp
protobuf

我的错误

代码语言:javascript
复制
  Found existing installation: numpy 1.23.1
    Uninstalling numpy-1.23.1:
      Successfully uninstalled numpy-1.23.1
  Running setup.py install for rpy2: started
  Running setup.py install for rpy2: finished with status 'error'
  error: subprocess-exited-with-error
  
  × Running setup.py install for rpy2 did not run successfully.
  │ exit code: 1
  ╰─> [172 lines of output]
      cffi mode is CFFI_MODE.ANY
      Looking for R home with: R RHOME
      R home found: /usr/lib/R
      R exec path: /usr/lib/R/bin/R
      Looking for R CONFIG with: /usr/lib/R/bin/R CMD config --ldflags
      ['-Wl,--export-dynamic -fopenmp -Wl,-z,relro -L/usr/lib/R/lib -lR -lpcre2-8 -llzma -lbz2 -lz -ltirpc -lrt -ldl -lm -licuuc -licui18n', '']
      R exec path: /usr/lib/R/bin/R
      Looking for R CONFIG with: /usr/lib/R/bin/R CMD config --cppflags
      ['-I/usr/share/R/include', '']
      cffi mode is CFFI_MODE.ANY
      Looking for R home with: R RHOME
      R home found: /usr/lib/R
      R exec path: /usr/lib/R/bin/R
      Looking for R CONFIG with: /usr/lib/R/bin/R CMD config --ldflags
      ['-Wl,--export-dynamic -fopenmp -Wl,-z,relro -L/usr/lib/R/lib -lR -lpcre2-8 -llzma -lbz2 -lz -ltirpc -lrt -ldl -lm -licuuc -licui18n', '']
      R exec path: /usr/lib/R/bin/R
      Looking for R CONFIG with: /usr/lib/R/bin/R CMD config --cppflags
      ['-I/usr/share/R/include', '']
      running install
      /usr/local/lib/python3.9/dist-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      cffi mode: CFFI_MODE.ANY
      running build_py
      file _rinterface_cffi_abi.py (for module _rinterface_cffi_abi) not found
      creating build
      creating build/lib.linux-x86_64-cpython-39
      creating build/lib.linux-x86_64-cpython-39/rpy2
      copying ./rpy2/__init__.py -> build/lib.linux-x86_64-cpython-39/rpy2
      copying ./rpy2/situation.py -> build/lib.linux-x86_64-cpython-39/rpy2
      copying ./rpy2/_rinterface_cffi_build.py -> build/lib.linux-x86_64-cpython-39/rpy2
      copying ./rpy2/rinterface.py -> build/lib.linux-x86_64-cpython-39/rpy2
      creating build/lib.linux-x86_64-cpython-39/rpy2/rlike
      copying ./rpy2/rlike/container.py -> build/lib.linux-x86_64-cpython-39/rpy2/rlike
      ## Some more copying added by the stackoverflow user ##
      copying ./rpy2/rinterface_lib/R_API_eventloop.c -> build/lib.linux-x86_64-cpython-39/rpy2/rinterface_lib
      copying ./rpy2/rinterface_lib/RPY2.h -> build/lib.linux-x86_64-cpython-39/rpy2/rinterface_lib
      copying ./rpy2/rinterface_lib/_bufferprotocol.c -> build/lib.linux-x86_64-cpython-39/rpy2/rinterface_lib
      file _rinterface_cffi_abi.py (for module _rinterface_cffi_abi) not found
      generating cffi module 'build/lib.linux-x86_64-cpython-39/_rinterface_cffi_abi.py'
      running build_ext
      generating cffi module 'build/temp.linux-x86_64-cpython-39/_rinterface_cffi_api.c'
      creating build/temp.linux-x86_64-cpython-39
      building 'rpy2.rinterface_lib._bufferprotocol' extension
      creating build/temp.linux-x86_64-cpython-39/rpy2
      creating build/temp.linux-x86_64-cpython-39/rpy2/rinterface_lib
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.9 -c rpy2/rinterface_lib/_bufferprotocol.c -o build/temp.linux-x86_64-cpython-39/rpy2/rinterface_lib/_bufferprotocol.o
      rpy2/rinterface_lib/_bufferprotocol.c:2:10: fatal error: Python.h: No such file or directory
          2 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> rpy2

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
The command '/bin/sh -c pip3 install --no-cache-dir -r requirements.txt' returned a non-zero code: 1

如何使用bookwormpython 3.9创建一个能够正确安装numpypandasrayrpy2库而不发生冲突的对接者映像。

EN

回答 1

Stack Overflow用户

发布于 2022-07-13 23:23:07

尝试一下;您仍然需要在python文件中进行复制。

代码语言:javascript
复制
FROM debian:bookworm-20210816-slim
RUN apt-get update
RUN apt-get update && apt-get install -y software-properties-common dirmngr wget
RUN add-apt-repository -y ppa:deadsnakes/ppa && apt-get install -y python3.9 python3.9-distutils
RUN wget https://bootstrap.pypa.io/get-pip.py && python3.9 get-pip.py && python3.9 -m pip install --upgrade pip
RUN wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc |  tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
RUN add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
RUN apt-get install -y --no-install-recommends r-base
RUN pip install pandas scipy ray rpy2 Werkzeug nltk Flask_Script pytest numba pymongo statsmodels \
    Flask_MonitoringDashboard pingouin flasgger cryptography Flask_RESTful Flask_Cors marshmallow \
    config_with_yaml Flask boto3 requests fastapi PyJWT scikit_learn pytz markupsafe itsdangerous pysftp protobuf
CMD ["python3.9", "manage.py", "run"]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72961842

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档