I have this Docker image
FROM debian
RUN apt-get update \
&& apt-get install -y \
autoconf \
build-essential \
bc \
curl \
git \
wget \
jq \
libssl-dev \
libtool \
net-tools \
openssl \
python3-pip \
pkg-config \
procps \
sed \
vim \
xxd \
ca-certificates \
gnupg \
dc \
zsh \
&& apt clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN pip install base58
and I get this error since 2 week
> [ 3/11] RUN pip install base58: #0 2.868 error: externally-managed-environment #0 2.868 #0 2.868 × This environment is externally managed #0 2.868 ╰─> To install Python packages system-wide, try apt install #0 2.868 python3-xyz, where xyz is the package you are trying to #0 2.868 install. #0 2.868 #0 2.868 If you wish to install a non-Debian-packaged Python package, #0 2.868 create a virtual environment using python3 -m venv path/to/venv. #0 2.868 Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make #0 2.868 sure you have python3-full installed. #0 2.868 #0 2.868 If you wish to install a non-Debian packaged Python application, #0 2.868 it may be easiest to use pipx install xyz, which will manage a #0 2.868 virtual environment for you. Make sure you have pipx installed. #0 2.868 #0 2.868 See /usr/share/doc/python3.11/README.venv for more information. #0 2.868 #0 2.868 note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override
this, at the risk of breaking your Python installation or OS, by
passing –break-system-packages.
#0 2.868 hint: See PEP 668 for the detailed specification.
——
failed to solve: executor failed running [/bin/sh -c pip install base58]: exit code: 1
I have this error since two weeks, and I don’t understand how can I resolve it. I’m trying to create very slim image without lucky
>Solution :
A good practice when creating docker images is to set a tag to the image you are using to avoid breaking changes from version to version like so: FROM debian:12-slim
. Otherwise its going to use the latest
tag and download whatever is latest.
The message is very clear.
To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.
If you want it system-wide you are going to need to install it with apt instead of pip, apt install python3-base58
Or use a virtual environment