我一直在尝试在旧的 Raspberry Pi 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"]
Run Code Online (Sandbox Code Playgroud)
我尝试安装一些库build-essentials
,如gcc
、 等...但它不起作用...在操作系统(Raspberry Pi OS Lite)中安装这些软件包非常快,因为 pip 使用这些armhf
软件包。我尝试过的另一个选择是使用,但它需要raspbian/stretch
Python 3.5 附带的。安装Python的主要版本会使容器太大(或多或少1GB)......scipy
Python => 3.7
那么,有什么办法可以解决 pip install 的问题吗?
太感谢了!
问题是 pip 没有在https://piwheels.org/simple中搜索已编译的软件包版本。所以解决方案就是添加:
RUN pip install --index-url=https://www.piwheels.org/simple --no-cache-dir -r requirements.txt
Run Code Online (Sandbox Code Playgroud)
问题是 pip 没有在https://piwheels.org/simple中搜索已编译的软件包版本。所以解决方案就是添加:
RUN pip install --index-url=https://www.piwheels.org/simple --no-cache-dir -r requirements.txt
Run Code Online (Sandbox Code Playgroud)