[英]Docker on RaspberryPI does not install Pyyaml
I get the following error when trying to build a docker-image.尝试构建 docker-image 时出现以下错误。
Step 5/5 : RUN pip install -r requirements.txt
---> Running in e439307defa3
Collecting wakeonlan
Downloading wakeonlan-2.0.1-py3-none-any.whl (4.2 kB)
Collecting pyyaml
Downloading PyYAML-5.4.1.tar.gz (175 kB)
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/tarfile.py", line 2301, in utime
os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime))
PermissionError: [Errno 1] Operation not permitted
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 173, in _main
status = self.run(options, args)
File "/usr/local/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 203, in wrapper
return func(self, options, args)
File "/usr/local/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 315, in run
requirement_set = resolver.resolve(
File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 94, in resolve
result = self._result = resolver.resolve(
File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 472, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 341, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/resolvers.py", line 172, in _add_to_criteria
if not criterion.candidates:
File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/structs.py", line 151, in __bool__
return bool(self._sequence)
File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 140, in __bool__
return any(self)
File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 128, in <genexpr>
return (c for c in iterator if id(c) not in self._incompatible_ids)
File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 32, in _iter_built
candidate = func()
File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 204, in _make_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 295, in __init__
super().__init__(
File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
self.dist = self._prepare()
File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 227, in _prepare
dist = self._prepare_distribution()
File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 305, in _prepare_distribution
return self._factory.preparer.prepare_linked_requirement(
File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 508, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 550, in _prepare_linked_requirement
local_file = unpack_url(
File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 249, in unpack_url
unpack_file(file.path, location, file.content_type)
File "/usr/local/lib/python3.9/site-packages/pip/_internal/utils/unpacking.py", line 256, in unpack_file
untar_file(filename, location)
File "/usr/local/lib/python3.9/site-packages/pip/_internal/utils/unpacking.py", line 230, in untar_file
tar.utime(member, path)
File "/usr/local/lib/python3.9/tarfile.py", line 2303, in utime
raise ExtractError("could not change modification time")
tarfile.ExtractError: could not change modification time
The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 2
The dockerfile泊坞窗文件
FROM python:3
WORKDIR /usr/src/wakeonlan
COPY . .
RUN pip install --no-cache-dir --upgrade pip
# Install dependeces
RUN pip install -r requirements.txt
The requirements.txt includes pyyaml
and wakeonlan
requirements.txt 包括
pyyaml
和wakeonlan
Host OS:主机操作系统:
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
Docker version码头工人版本
Client: Docker Engine - Community
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:55:38 2021
OS/Arch: linux/arm
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.8
API version: 1.41 (minimum version 1.12)
Go version: go1.16.6
Git commit: 75249d8
Built: Fri Jul 30 19:53:31 2021
OS/Arch: linux/arm
Experimental: false
containerd:
Version: 1.4.8
GitCommit: 7eba5930496d9bbe375fdf71603e610ad737d2b2
runc:
Version: 1.0.0
GitCommit: v1.0.0-0-g84113ee
docker-init:
Version: 0.19.0
GitCommit: de40ad0
I tried reinstalling docker and deleting cached images.我尝试重新安装 docker 并删除缓存的图像。 The Problem does only occur on the Raspberry.
问题只发生在树莓上。 On Windows and an Ubuntu-VM the image can be built without any problem.
在 Windows 和 Ubuntu-VM 上,可以毫无问题地构建映像。
Same problem here.同样的问题在这里。
I've just migrate some dockerized python apps from a Ubuntu Server to a Raspberry and I've had to change every Dockerfile to user the "-buster" version.我刚刚将一些 dockerized python 应用程序从 Ubuntu Server 迁移到 Raspberry,我不得不更改每个 Dockerfile 以使用“-buster”版本。
FROM python:3-buster #python:buster also works
...
Why?为什么? I still don't know, but i tried this (because when I was installing raspberry os I've read buster some many times) and it works.
我仍然不知道,但是我尝试了这个(因为当我安装 raspberry os 时,我已经多次阅读了 buster)并且它有效。
I am having the exact same issue (albeit with a different image), and after going down a number of rabbit holes and running into several other errors, I've found a (somewhat ugly) workaround, which is to use the ubuntu 18.04 base image.我遇到了完全相同的问题(尽管图像不同),在经历了许多兔子洞并遇到了其他几个错误之后,我找到了一个(有点丑陋的)解决方法,即使用 ubuntu 18.04 基础图片。 This only supports up to python 3.6 as far as I can tell, and a few hacks are necessary to get everything to install properly, but at least for me it works.
据我所知,这最多只支持 python 3.6,并且需要一些技巧才能正确安装所有内容,但至少对我来说它是有效的。 Here is the relevant part of my Dockerfile:
这是我的 Dockerfile 的相关部分:
# set base image (host OS)
FROM ubuntu:18.04
RUN apt-get update --allow-unauthenticated --allow-insecure-repositories && apt-get -y --allow-unauthenticated install curl python3 python3-pip
RUN apt install python3-markupsafe
ENV LC_CTYPE en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LC_ALL C.UTF-8
# set the working directory in the container
WORKDIR /code
# copy the dependencies file to the working directory
COPY requirements.txt .
# install dependencies
RUN pip3 install -r requirements.txt
Specifically, I had to use apt to install python3-markupsafe (instead of via pip), set the --allow-unauthenticated
and --allow-insecure-repositories
flags when doing apt-get update, and set the language encoding to utf-8 via environment variables.具体来说,我必须使用 apt 来安装 python3-markupsafe(而不是通过 pip),在执行 apt-get 更新时设置
--allow-unauthenticated
和--allow-insecure-repositories
标志,并将语言编码设置为 utf- 8 通过环境变量。
I was unable to successfully build an image with any of the python base image versions or with debian:11 or ubuntu:20.04.我无法使用任何 python 基础映像版本或 debian:11 或 ubuntu:20.04 成功构建映像。
Hopefully this helps in the meantime until a proper solution is found.希望这在此期间有所帮助,直到找到合适的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.