我一直在尝试为一台旧的树莓派2B在Docker镜像中安装numpy,pandas和scipy。当pip尝试安装它们时,问题就来了,它花费了太多的时间(甚至失败)。我一直使用的Dockerfile是:
FROM arm32v7/python:3.7-slim-buster
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
# Install pip requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Workdir
WORKDIR /book
# Switching to a non-root user
RUN useradd appuser && chown -R appuser /book
USER appuser
# During debugging, this entry point will be overridden.
CMD [ "jupyter", "notebook", "--no-mathjax", "--no-browser", "--port", "4000"]我试着安装了一些库,比如build-essentials、gcc等等。但它并没有起作用。在操作系统(Raspberry Pi OS Lite)中安装这些包是相当快的,因为pip使用了armhf包。我尝试过的另一个选择是使用raspbian/stretch,但它是随Python3.5一起提供的,而scipy需要Python => 3.7。安装Python的主要版本会使容器太大(或多或少1 1GB)……
那么,有没有办法解决pip安装问题呢?
非常感谢!
更新:
问题是pip没有在:https://piwheels.org/simple中搜索已经编译过的包版本。因此,解决方案只需添加:
RUN pip install --index-url=https://www.piwheels.org/simple --no-cache-dir -r requirements.txt发布于 2021-06-09 03:04:04
问题是pip没有在:https://piwheels.org/simple中搜索已经编译过的包版本。因此,解决方案只需添加:
RUN pip install --index-url=https://www.piwheels.org/simple --no-cache-dir -r requirements.txthttps://stackoverflow.com/questions/66373417
复制相似问题