platformio-core/issues/3700, and many other recent issues in that repository, are about some platformio dependency not yet supporting python 3.9. The linked issue describes a workaround for fedora 33.

My approach does not require changing settings or disabling builtins.

My setup

I use fish as main shell; in fish I use pyenv and virtualfish.

The following steps should find their equivalents in other shells too: if you know how to create a virtualenv using a specific python version, you should be able to replicate the result.

How to make PlatformIO use a specific python version

  1. Don’t have vscode running and don’t have the platformio extension installed.
  2. Install latest python 3.8:
     $ pyenv install 3.8.6
    

    This might take a few minutes to compile; also might complain about missing packages. …and this is where it gets too platform specific.

  3. Create a virtual environment for platformio/vscode:
     $ vf new -p 3.8 platformio
    

    (I could not specify 3.8.6 but only 3.8; and virtualfish found 3.8.5 first. Later I could vf upgrade --rebuild --python 3.8 to get 3.8.6 🤷)

  4. Activate said virtual environment and start vscode:
     $ vf activate platformio
     $ code
    

    (The binary is called code on my system.)

  5. Install the extension in vscode.