首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Docker :如何安装用于armv7体系结构的python包和numpy、scipy和大熊猫(Armv7)?

Docker :如何安装用于armv7体系结构的python包和numpy、scipy和大熊猫(Armv7)?
EN

Stack Overflow用户
提问于 2021-09-21 07:34:07
回答 1查看 631关注 0票数 0

我正在尝试构建一个Docker映像,它应该运行一个python脚本,它需要numpyscipypandasgoogle-cloud-bigquery

由于这个映像是为armv7架构而构建的,所以直接安装numpy、scipy和大熊猫是件很痛苦的事情(它花费的时间太长了,最后它崩溃了)。所以我决定用Miniconda来包装Raspberry Pi。这很好(安装可以在映像构建期间完成)。

现在我正在尝试安装google google-crc32c==1.1.2google-cloud-bigquery。有了pip,这是可能的,并且图像是正确构建的。但是,如果我使用这个映像运行一个容器,它总是重新启动并给出这个错误日志:

代码语言:javascript
复制
File "/usr/src/app/bigquery.py", line 1, in <module>
    from google.cloud import bigquery
ImportError: No module named 'google'

我认为我必须用conda安装google软件包,但是armv7体系结构没有可用的包:

google-cloud-bigquery包在Anaconda.org:https://anaconda.org/search?q=google+bigquery

google-crc32c包在Anaconda.org:https://anaconda.org/search?q=google-crc32c

是否有可能为armv7架构安装那些带有Miniconda的google?或者,另一种不使用迷你熊猫(但不是直接安装它们)的方法可以安装矮胖、枕木和熊猫吗?

谢谢你的帮助!

文档:

代码语言:javascript
复制
FROM python:3.7-buster

WORKDIR /usr/src/app

ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"

COPY main_prog.py bigquery.py requirements.txt ./

RUN wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-armv7l.sh
RUN mkdir /root/.conda
RUN /bin/bash Miniconda3-latest-Linux-armv7l.sh -b
RUN rm -f Miniconda3-latest-Linux-armv7l.sh \
    && echo "Running $(conda --version)"

RUN wget https://github.com/jjhelmus/berryconda/releases/download/v2.0.0/Berryconda3-2.0.0-Linux-armv7l.sh
RUN chmod +x Berryconda3-2.0.0-Linux-armv7l.sh ./Berryconda3-2.0.0-Linux-armv7l.sh
   
RUN conda list \
    && conda config --add channels rpi \
    && conda install python=3.6 -y\
    && conda install openblas blas -y\
    && conda install numpy -y\
    && conda install pandas -y\
    && conda install scipy -y

RUN pip install --upgrade pip

RUN pip install "google-crc32c==1.1.2"
RUN pip install google-cloud-bigquery

CMD ["python", "main_prog.py"]
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-23 08:08:00

我无法找到安装所有软件包的方法。

但我可以直接用转轮的轮子安装它们。为此,我不得不在“pip.conf”目录中添加一个/etc文件。

pip.conf含量

代码语言:javascript
复制
[global]
extra-index-url=https://www.piwheels.org/simple

此外,我还必须安装libatlas-base-dev。我只能通过在"/etc/apt/“目录中向我的deb http://ftp.de.debian.org/debian buster main添加一个URL deb http://ftp.de.debian.org/debian buster main(就像推荐的这里)来做到这一点。

sources.list含量

代码语言:javascript
复制
# deb http://snapshot.debian.org/archive/debian/20210902T000000Z buster main
deb http://deb.debian.org/debian buster main
# deb http://snapshot.debian.org/archive/debian-security/20210902T000000Z buster/updates main
deb http://security.debian.org/debian-security buster/updates main
# deb http://snapshot.debian.org/archive/debian/20210902T000000Z buster-updates main
deb http://deb.debian.org/debian buster-updates main
deb http://ftp.de.debian.org/debian buster main

Dockerfile:

代码语言:javascript
复制
FROM python:3.7-buster

WORKDIR /usr/src/app

COPY main_prog.py bigquery.py requirements.txt pip.conf sources.list ./

RUN mv ./pip.conf /etc \
    && export PIP_CONFIG_FILE=/etc/pip.conf

RUN mv ./sources.list /etc/apt/

RUN apt-get update \
    && apt-get upgrade -y

RUN apt-get install libatlas-base-dev -y
RUN pip3 install --upgrade pip

RUN pip3 install numpy \
    && pip3 install scipy \
    && pip3 install pandas \
    && pip3 install google-crc32c \
    && pip3 install google-cloud-bigquery

CMD ["python", "main_prog.py"]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69265038

复制
相关文章

相似问题

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