【问题标题】:Building Python IoTEdge Module for Raspberry Pi为 Raspberry Pi 构建 Python IoTEdge 模块
【发布时间】:2021-03-31 17:50:17
【问题描述】:

我正在尝试为 Raspberry Pi 4 构建 Python IoTEdge 模块(使用 Docker 构建映像)。

我将 IoTEdge 解决方案的目标架构设置为 arm32v7

我认为我的requirements.txt 没有任何问题,仅供参考:

requirements.txt

azure-iot-device~=2.0.0
opencv-python
numpy
requests

Dockerfile

FROM arm32v7/python:3.7-slim-buster

WORKDIR /app

COPY requirements.txt ./
RUN pip install -r requirements.txt

COPY . .

CMD [ "python3", "-u", "./main.py" ]

我运行以下命令:

docker build  --rm -f "path/to/Dockerfile" -t dockerTag "path/to/module/project"

但是,我收到以下错误:

Step 4/7 : RUN pip install -r requirements.txt
 ---> Running in 515aac4bdc38
standard_init_linux.go:219: exec user process caused: exec format error

我读到 here 说要构建到 ARM,我必须改用 docker buildx。我用--platform linux/arm32 创建了一个buildx 容器。我切换到使用这个容器,然后运行:

docker buildx build --platform linux/arm32 --rm -f "path/to/Dockerfile" -t dockerTag "path/to/module/project"

但是,现在我明白了:

 => ERROR [4/7] RUN pip install -r requirements.txt                                                                                                                        2.2s
------                                                                                                                                                                          
 > [4/5] RUN pip install -r requirements.txt:
#8 0.727 standard_init_linux.go:219: exec user process caused: exec format error
------
Dockerfile.arm32v7:22
--------------------
  20 |     #     libcurl4-openssl-dev
  21 |     
  22 | >>> RUN pip install -r requirements.txt
  23 |     
  24 |     COPY . .
--------------------
error: failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1

我的开发机器:

  • 芯片:Intel i7 4510u
  • 操作系统:Manjaro KDE

我也尝试直接在 Raspberry Pi 4 本身上构建它,但是,它给了我同样的错误。 我不知道该怎么办。有什么建议吗?

【问题讨论】:

  • 试试 pip install --no-binary
  • @Joe 不幸的是,它会导致相同的错误:(

标签: python docker raspberry-pi azure-iot-edge azure-container-registry


【解决方案1】:

奇怪的是,当我在 Windows 机器上而不是使用 Manjaro Linux 时,它成功构建了。我仍然想知道为什么...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-03
    • 2018-09-25
    • 2021-09-22
    • 2021-04-16
    • 2015-11-14
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多