We have been getting this error after doing a balena “push”, this is on the stage where we did a “RUN pip install --upgrade pip”. The error is this:
[lora] Setting up libgd3:armhf (2.3.3-9ubuntu5) …
[lora] Setting up libc-devtools (2.39-0ubuntu8.3) …
[lora] Processing triggers for libc-bin (2.39-0ubuntu8.3) …
[lora] Removing intermediate container f023a040a527
[lora] —> 2db544ceef85
[lora] Step 7/29 : RUN pip install --upgrade pip
[lora] —> Running in ae4a31963c31
[lora] error: externally-managed-environment
[lora] × This environment is externally managed
[lora] ╰─> To install Python packages system-wide, try apt install
[lora] python3-xyz, where xyz is the package you are trying to
[lora] install.
[lora] If you wish to install a non-Debian-packaged Python package,
[lora] create a virtual environment using python3 -m venv path/to/venv.
[lora] Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
[lora] sure you have python3-full installed.
[lora] If you wish to install a non-Debian packaged Python application,
[lora] it may be easiest to use pipx install xyz, which will manage a
[lora] virtual environment for you. Make sure you have pipx installed.
[lora] See /usr/share/doc/python3.12/README.venv for more information.
[lora] 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.
[lora] hint: See PEP 668 for the detailed specification.
[lora]
[lora] Removing intermediate container ae4a31963c31
[lora] The command ‘/bin/sh -c pip install --upgrade pip’ returned a non-zero code: 1
[Info] Uploading images
[Success] Successfully uploaded images
[Error] Some services failed to build:
[Error] Service: lora
[Error] Error: The command ‘/bin/sh -c pip install --upgrade pip’ returned a non-zero code: 1
[Info] Built on 7088c3b
[Error] Not deploying release.
Remote build failed
Our previous pushes has been successful in the past, so this is a bit weird.
Have you tried installing and using the pipx Ubuntu package instead of pip? It’s best practice to install Python libraries in virtual environments whenever possible and that is what this error is trying to convey.
Hi @joshbwlng , thanks for responding. We have not tried using “pipx” because we have not encountered this error in the past pushes before. So before we try editing our scripts, I would like to know if there were any recent changes on the Balena cloud side that is the main cause for this error. Thanks.
@louie This error is unrelated to balenaCloud, its thrown by Ubuntu itself during the image build. You should be able to reproduce the error when attempting to build the image locally.
@louie I’m not sure without seeing your Dockerfile. The error you’re running into is from Ubuntu error while docker is attempting to execute a step to build your image, meaning it’s not an error thrown by balenaCloud. Have you updated your base image recently or perhaps is it using the latest tag and the latest now points to a different image version than before?
@joshbwlng , just a quick background I’m not too familiar with Docker (I am more into firmware), we already have this existing file that we use in the past and was working well according to my teammates so I was expecting it to work out of the box as well. Here is a snippet of the Dockerfile, I cut it off until the “pip” error part:
FROM balenalib/raspberrypi3-ubuntu
ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN install_packages software-properties-common
RUN add-apt-repository universe
RUN apt-get update && apt-get install -y #apache2
curl
git
python3
python3-pip
network-manager
Thanks @mpous , this is some legacy code that I have inherited and as much as possible I wouldn’t want to change it to avoid breaking stuff. It was working when one of my teammates did a push in the past(about a month ago), but now it is breaking when he tried to push again today. I also tried pushing a couple of times yesterday with the same error.