Need Python3.12

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.