In short, you can’t. There’s no Python interpreter available in the Forge Runtime.
To explain, The Forge Runtime is not an arbitrary computing environment. What the docs explain is:
At the heart of Forge is a serverless FaaS hosting platform, powered by AWS Lambda. Apps created with Forge run inside a security layer that enforces tenancy isolation and data egress restriction by design.
Elaborated over subsequent docs is the Forge Runtime is effectively a Node.js environment with a tenant-focused security model that severely limits access to infrastructure.
I would 2nd @PaoloCampanelli’s prior answer, elaborating that Forge is not itself a general purpose AI/ML development platform. If you want to understand how to mix the Forge with AI, I’d recommend starting with @dmorrow’s blog post on Forge AI Basics. With that, you might better understand what Paolo is suggesting in a mixed architecture using Forge Remote, where you would substitute your own “back-end” for what Dugald has illustrated with OpenAI.