How to fix PlatformIO: ‘Can not find working Python 3.6+ interpreter’ on Linux

Problem:

When trying to open PlatformIO in Visual Studio Code, you see the following error message:

PlatformIO: Can not find working Python 3.6+ Interpreter. Please install the latest Python 3 and restart VSCode

even though you have Python3 already installed.

Solution:

The issue here is not that PlatformIO can’t find Python 3, it is that you don’t have venv (virtual environments) installed for your Python version!

On Ubuntu/Debian, you can install it using

sudo apt -y install python3-venv

Alternatively you can install it using pip:

pip install virtualenv