Error "ModuleNotFoundError: No module named 'pkg_resources'" after upgrading 'py3-setuptools' package in Alpine Linux container

Error "ModuleNotFoundError: No module named 'pkg_resources'" after upgrading 'py3-setuptools' package in Alpine Linux container

I'm using 'boky/postfix' docker image for emails sending from my Kubernetes-cluster. Recently security scanning system started alerting me about vulnerability in the 'py3-setuptools' package (Alpine Linux), which I can mitigate by upgrading that package to the latest version.

As usually, I'm going to my custom Dockerfile and updating string for explicit package upgrade...

RUN apk upgrade busybox expat py3-setuptools --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main

... and after starting the container I'm getting loooong trace with error message "ModuleNotFoundError: No module named 'pkg_resources'" in the end.

What is interesting, is that the same package is adding module 'pkg_resources'!

Going to read/investigate. Can't find anything useful. Decided to try like that:

RUN apk upgrade busybox expat py3-setuptools --repository=http://dl-cdn.alpinelinux.org/alpine/edge/main
# This section is needed because of upgrade of 'py3-setuptools'.
RUN apk add py3-pip
RUN pip install setuptools
# /This section is needed because of upgrade of 'py3-setuptools'.

Helped! Everything running as it should.

linux (en), docker (en), containers (en)

  • Hits: 54
Add comment

Related Articles