Need Python3.12

Using the verdin iMX8MP on an IVY plus board.
Using the 7.3.0 version of torizon build 239.
The device has python version 3.12. When we setup the dockerfile, it is installing python3.11 which is not working for us. We need 3.12. If I put that in the requirement, it says it can’t find it.
Is the files it’s pulling from an older OS version? if so, how do I get it to pull from the 7.3.0 version?
So currently it is downgrading the container version of python on the OS it’s running on.
How do I fix this?

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for your detailed question.

When working with Torizon and Docker containers, the Python version inside your container is determined by the base image you choose in your Dockerfile—not by the Python version installed on the host OS itself. By default, some older images may use Debian “bullseye,” which currently provides Python 3.11. For Python 3.12, you should use a newer base image based on Debian “bookworm,” which includes Python 3.11+ and the most up-to-date packages see reference.

How to ensure Python 3.12 in your Docker container:

  1. Use the correct base image:
    In your Dockerfile, explicitly select a Torizon base image based on Debian bookworm (used in Torizon OS 6/7 series).

    FROM --platform=$ARCH_ARG torizon/debian:3-bookworm
    

    This ensures compatibility with TorizonCore 7.3.0 and Python 3.12 availability.

  2. Install Python 3.12 (if not already present):
    After choosing a bookworm-based image, you can install the desired Python version:

    RUN apt-get update && apt-get install -y python3 python3-pip
    

    On Debian bookworm, python3 will point to Python 3.11 by default, but Python 3.12 may need to be explicitly installed or added from the deadsnakes repository or by using stock images updated for 3.12.

    To be sure which version you get, check inside the container:

    RUN python3 --version
    
  3. Clean up Docker caches (to avoid pulling old layers):

    • On your development PC:
      docker system prune -a
      
    • On your target board:
      docker system prune -a
      

    Reference

  4. Verify your deployment:
    After building and running the new container, SSH into the running container and type:

    python3 --version
    

    You should see Python 3.12.x.

Summary:

  • Use a torizon/debian:3-bookworm base image.
  • Install the latest Python (python3) package.
  • Clean Docker caches and rebuild your container.

If you require a more specialized image or want to guarantee Python 3.12 specifically, you may need to create a custom Docker image based on a suitable upstream Debian bookworm image or await updated Toradex images if 3.12 is not yet the default.

For a step-by-step sample, check this official guide for Torizon with Python and Machine Learning.

Let me know if you need example Dockerfiles or further assistance!

Best regards,
Toradex AI Assistant.

When I use torizon/debian:3-bookworm, I still see python 3.11 being setup. In the container, I still get:
python3 --version
Python 3.11.2

Hey @EvetsMostel1

The application, running under a Container, is detached from the OS. The Python that is used by our templates follows the version from the Debian release: Debian – Details of package python3 in bookworm

If you want another version, you will need to use something else, like pyenv or uv.

BR,

@matheus.tx
I have a .deb file that is arm64 that would work, but I can’t get it to find it in the local directory. Do I have to do a full path or something special?

Hi @EvetsMostel1

What do you mean by it can’t find it? Do you have an error message or log you can share?

My guess is it’s probably container volume related but hard to say until I understand it better.

Drew

@drew.tx
OK, well apparently you can COPY a file to /tmp/ then do an apt install file.deb from there. So that’s the answer to that problem.
However the python3.12 I found that has been compiled for arm64, has 7 non-dev and non-debug .deb files to install. Trying to find the correct order install them, and some missing libs (libffi7 and libssl1.1, which is obsolete), has proven to be difficult. I think those last two are my final sticking point.

Hi @EvetsMostel1

I suppose you can base your container on an older version of Debian. It may not be the easiest thing to do given that our reference containers start with fresh versions but given your requirements here that may be a solution. We still have our older reference containers based off of bullseye that might work for you.

Drew