Multiple Python Versions on Linux. Finds 2

Ubuntu 20.10. Python3 v 3.8.6 and Python 2.7.18.

Platformio 2.2.1 on vscode:
Error: Python 3.6 or later is required for this operation. Please check a
migration guide:

The convention on linux is that python is a symlink to python2 when both are installed, and python3 is a symlink to python3. Vscode/Platformio keeps finding 2. Is there a platformio specific setting for this??? I have other stuff that needs python2, and telling me to change the symlink will just move the problem to others’ backyards.

In the VSCode settings for python, theres a “default interpreter path” option, you should be able to set the python3 path there.


1 Like

That didnt work. I set it everywhere I could find

Right then, It should be using it if you have configured it. What do you get if you open a terminal inside VSCode (from the menubar) and type python --version? I would expect the one you configured.

Close that terminal.

if you got 3.x, open the PlatformIO terminal next, left side, click ant/alien head icon, look for an option to open a terminal.

Execute python --version again. Same result? Wrong?

There’s a PlatformIO option to use a portable python interpreter:

Platformio-ide: Use Builtin Python
“Use a portable python 3 interpreter if available” – if you tick/check that, it will use the python 3 interpreter that it downloaded into ~/.platformio/penv/bin.

There are three pythons there, python, python3 and python3x - they are symlinks to either the system wide python3 interpreter, or, to the downloaded python3 interpreter as appropriate.

~/.platformio/penv/bin/python --version should give you a 3.x version and using the “portable” interpreter in VSCode should also give the same version – if the option has “stuck”.


You may also just try and install it locally per docs. When you reinstall the VSCode PlatformIO extension, it should automatically pick up the existing core.

I just downloaded a clean Ubuntu 20.10 ISO image and started a virtual machine with it and installed it. I fully updated the installation with sudo apt update && sudo apt upgrade. Then installed VSCode from the .deb file.

First installation of PlatformIO gives


which tellls you to sudo apt install python3-distutils.

After doing that and a VSCode restart, it begins to install the PlatformIO core. Which works



Other info

max@ubuntu:~$ cat /etc/lsb-release 
max@ubuntu:~$ uname -a
Linux ubuntu 5.8.0-41-generic #46-Ubuntu SMP Mon Jan 18 16:48:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

So I can just recommend to update all packages and try with a clean VSCode installation, from the .deb. (not the snap or anything else)