Support for Python 3.11?

Hi, I deployed an app built on Python 3.11.4 but it’s failing. Looking at the deploy output, I see a reference to 3.10:

Selected CPython version (using ): 3.10.12

I also see this in the monitor that is specific to code introduced in python 3.11:

ImportError: cannot import name 'StrEnum' from 'enum' (/layers/paketo-buildpacks_cpython/cpython/lib/python3.10/

Can it please be confirmed that Python 3.11.x is supported in v2 apps? Thanks.

Yes. Python 3.11.x is supported. runs Linux VMs. So we don’t have the notion of “supported language runtime versions” generally speaking.

Seems your error is mentioning Buildpacks. Can you show us your fly.toml?

Thank you for your reply and confirming. Below is the fly.toml generated when fly launch is run:

# fly.toml app configuration file generated for my-app on 2023-08-06T22:55:19-07:00
# See for information about how to use this file.

app = "my-app"
primary_region = "lax"

  builder = "paketobuildpacks/builder:base"

  PORT = "8080"

  internal_port = 8080
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

Also, I updated the fly.toml file with the entries below but still uses Python 3.10

  builder = "paketobuildpacks/builder:base"
  buildpacks = [""]
  builtin = "python"

  pythonbase = "3.11-slim-buster"

fly deploy output:

Status: Image is up to date for
Selected CPython version (using ): 3.10.12

How do I get Python 3.11.x?

According to these docs, try setting the BP_CPYTHON_VERSION environment variable.

Alternatively, you could switch to just using docker using the official python 3.11 image as a base.

Thanks, I added this to the [env] section of my fly.toml but fly deploy still selects Python 3.10.12

Can please upgrade their Python Buildpack?

Hi @hbcondo,

dyc3 had the right answer. You need to set BP_CPYTHON_VERSION to the version of Python you want. The buildpack itself is updated from Github every time you build, so there’s nothing to upgrade on’s side.

Try setting this in your fly.toml:


With this, my fly deploy output includes:

    Selected CPython version (using BP_CPYTHON_VERSION): 3.11.4

Note it has to be set as a build-time environment variable, not a run-time one, so it goes in [build.args] and not in [env].

1 Like

@roadmr, thank you for writing out a complete solution…it worked. I am not the only one with this question, it would be nice if the usage of BP_CPYTHON_VERSION was documented somewhere on developer documentation · Fly Docs

1 Like