【发布时间】:2021-11-14 18:55:02
【问题描述】:
我正在尝试构建一个应该运行 python 脚本的 Docker 映像,该脚本需要 numpy、scipy、pandas 和 google-cloud-bigquery。
由于此映像是为 armv7 架构构建的,因此直接安装 numpy、scipy 和 pandas 是一件很痛苦的事情(它花费了太长时间,最后它坏了)。所以我决定使用 Miniconda 并使用 Raspberry Pi 的包。效果很好(可以在映像构建期间完成安装)。
现在我正在尝试安装 google 软件包 google-crc32c==1.1.2 和 google-cloud-bigquery。使用 pip 这是可能的,并且图像可以正确构建。但是,如果我用这个 Image 运行一个容器,它总是会重新启动并给我这个错误日志:
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
是否有可能使用 Miniconda 为 armv7 架构安装这些 google 软件包? 或者是否可以在不使用 miniconda(但不直接安装它们)的情况下安装 numpy、scipy 和 pandas 的另一种方法?
感谢您的帮助!
Dockerfile:
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"]
【问题讨论】:
-
你看过这个question with similar issue。不一样的架构,但也许有些想法会奏效。
-
是的,我见过这个,但不幸的是,这对我没有帮助。我可以从link 安装带有轮子的软件包。所以我不再用 Miniconda 安装它们了。
标签: python google-bigquery dockerfile miniconda armv7