[英]Building Python IoTEdge Module for Raspberry Pi
I am trying to build a Python IoTEdge module for a Raspberry Pi 4 (uses Docker to build image).我正在尝试为 Raspberry Pi 4 构建 Python IoTEdge 模块(使用 Docker 构建图像)。
I set the target architecture for my IoTEdge solution as arm32v7
我将 IoTEdge 解决方案的目标架构设置为
arm32v7
I don't believe anything is wrong with my requirements.txt
, but just for reference:我不相信我的
requirements.txt
有什么问题,但仅供参考:
requirements.txt要求.txt
azure-iot-device~=2.0.0
opencv-python
numpy
requests
Dockerfile 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" ]
I run the following command:我运行以下命令:
docker build --rm -f "path/to/Dockerfile" -t dockerTag "path/to/module/project"
However, I get the following error:但是,我收到以下错误:
Step 4/7 : RUN pip install -r requirements.txt
---> Running in 515aac4bdc38
standard_init_linux.go:219: exec user process caused: exec format error
I read here that to build to ARM, I have to use docker buildx
instead.我在这里读到要构建到 ARM,我必须改用
docker buildx
。 I created a buildx
container with --platform linux/arm32
.我用
--platform linux/arm32
创建了一个buildx
容器。 I switched to using this container, and run:我切换到使用这个容器,然后运行:
docker buildx build --platform linux/arm32 --rm -f "path/to/Dockerfile" -t dockerTag "path/to/module/project"
However, now I get:但是,现在我得到:
=> 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
My development machine:我的开发机器:
I also tried to build it directly on the Raspberry Pi 4 itself, but alas, it gave me the same errors.我也尝试直接在 Raspberry Pi 4 本身上构建它,但是,它给了我同样的错误。 I'm at a loss of what to do.
我不知道该怎么办。 Any suggestions?
有什么建议么?
Oddly enough, it successfully built when I was on a Windows machine, instead of using Manjaro Linux.奇怪的是,当我在 Windows 机器上而不是使用 Manjaro Linux 时,它成功构建。 I still wonder why...
我还是想知道为什么...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.