python - 为 Raspberry Pi 构建 Python IoTEdge 模块
问题描述
我正在尝试为 Raspberry Pi 4 构建 Python IoTEdge 模块(使用 Docker 构建映像)。
我将 IoTEdge 解决方案的目标架构设置为arm32v7
我不相信我的 有什么问题requirements.txt
,但仅供参考:
要求.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
我在这里读到要构建到 ARM,我必须使用它docker buildx
。我buildx
用--platform linux/arm32
. 我切换到使用这个容器,然后运行:
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
我的开发机器:
- 芯片:英特尔 i7 4510u
- 操作系统:Manjaro KDE
我也尝试直接在 Raspberry Pi 4 本身上构建它,但是,它给了我同样的错误。我不知道该怎么办。有什么建议么?
解决方案
奇怪的是,当我在 Windows 机器上而不是使用 Manjaro Linux 时,它成功构建了。我还是想知道为什么...
推荐阅读
- laravel - 如何获取相关模型的相关laravel模型
- java - 如何使用私有 ssl 证书连接到私有 url
- excel - 如何从 VBA Excel 抓取 Googlemaps?
- javascript - 可以在 AST 树中搜索第一个节点之后的节点的自定义 ESLint 规则
- firebase - Firebase 和 admob 无法链接
- linux - 连接变量的问题,cat 和 cut 命令的结果
- php - 我想使用某些条件进行排名
- python - 从 CSV 文件 Python 中提取列:ValueError: too many values to unpack (expected 4)
- c# - 如何在 Razor 中动态设置变量?
- postgresql - How to find postgresql query which is consuming the most I/O