Docker Community Forums

Share and learn in the Docker community.

Error when building and installing pyyaml


i get the following error when build a dock-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/", 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/", line 173, in _main
    status =, args)
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/cli/", line 203, in wrapper
    return func(self, options, args)
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/commands/", line 315, in run
    requirement_set = resolver.resolve(
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/", line 94, in resolve
    result = self._result = resolver.resolve(
  File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/", line 472, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/", 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/", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "/usr/local/lib/python3.9/site-packages/pip/_vendor/resolvelib/", line 151, in __bool__
    return bool(self._sequence)
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/", line 140, in __bool__
    return any(self)
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/", 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/", line 32, in _iter_built
    candidate = func()
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/", 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/", line 295, in __init__
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/", line 156, in __init__
    self.dist = self._prepare()
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/", line 227, in _prepare
    dist = self._prepare_distribution()
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/", line 305, in _prepare_distribution
    return self._factory.preparer.prepare_linked_requirement(
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/", 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/", line 550, in _prepare_linked_requirement
    local_file = unpack_url(
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/operations/", line 249, in unpack_url
    unpack_file(file.path, location, file.content_type)
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/utils/", line 256, in unpack_file
    untar_file(filename, location)
  File "/usr/local/lib/python3.9/site-packages/pip/_internal/utils/", line 230, in untar_file
    tar.utime(member, path)
  File "/usr/local/lib/python3.9/", 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


FROM python:3
WORKDIR /usr/src/wakeonlan
COPY . .
RUN pip install --no-cache-dir --upgrade pip
# Install dependeces
RUN pip install -r requirements.txt



Host OS:

PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION="10 (buster)"

Docker version:

Docker version 20.10.7, build f0df350

Can you please help me to fix this error. Error does not occure on Windows or Ubuntu.

Thank you in advance and have a nice day

I just ran into this issue too on a Rpi4 running RasperrypiOS, it has something to do with the standard Python3 image. Someone here suggested using python:3-buster.

I can confirm, using python:3.9-buster, I was able to successfully build my docker image and run the container on RaspberrypiOS