If venv is not installed, PIO incorrectly reports that Python 3 is missing rather than the venv module, and instructs the user to install Python 3 and restart.
Following those instructions doesn't help, as the venv dependency remains unsatisfied.
Solution:
The output of .../get-platformio-1.2.2.py check python already does show the correct reason why the check failed, as evidenced by the developer tools console log.
Low-effort solution: \
Simply displaying the Reason line of that output in VSCode would let the user know why the check failed, so that information would no longer be masked by the extension and hidden from the user.
High-effort solution: \
Actually detecting the absence of venv at install time by parsing the Reason line or by sending/interpreting an alternate status code from the check python step would allow the installer to handle the absence of the venv package as a separate fault with different resolution steps. This would make the code more complicated, but it would simplify the install process for people with less familiarity with Python.
Error Details and Output:
In VSCode:
PlatformIO: Can not find a working Python 3.6+ Interpreter.
Please install the latest Python3 and restart VSCode
Developer Tools Console:
[Extension Host] runCommand /bin/python3 (3) ['/home/tylerl/.platformio/.cache/tmp/get-platformio-1.2.2.py', 'check', 'python']0: "/home/tylerl/.platformio/.cache/tmp/get-platformio-1.2.2.py"1: "check"2: "python"length: 3[[Prototype]]: Array(0) {spawnOptions: {…}, _id: '/bin/python3-0.5960698500644768'}
console.ts:137 [Extension Host] /bin/python3 Error: Error: The Python 3.11.8 (/bin/python3) interpreter is not compatible.
Reason: Could not find Python `venv` module
at /home/tylerl/.vscode-server/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:5261
at ChildProcess.i (/home/tylerl/.vscode-server/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:4559)
[....]
console.ts:137 [Extension Host] runCommand /bin/python (3) ['/home/tylerl/.platformio/.cache/tmp/get-platformio-1.2.2.py', 'check', 'python'] {spawnOptions: {…}, _id: '/bin/python-0.40082564509572616'}
console.ts:137 [Extension Host] /bin/python Error: Error: The Python 3.11.8 (/bin/python) interpreter is not compatible.
Reason: Could not find Python `venv` module
at /home/tylerl/.vscode-server/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:5261
at ChildProcess.i (/home/tylerl/.vscode-server/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:4559)
[....]
VSCode: 1.88.1 PIO IDE: v3.3.3
Problem:
[$HOME/.platformio/.cache/tmp/get-platformio-1.2.2.py', 'check', 'python']
Solution:
The output of
.../get-platformio-1.2.2.py check python
already does show the correct reason why the check failed, as evidenced by the developer tools console log.Low-effort solution: \ Simply displaying the
Reason
line of that output in VSCode would let the user know why the check failed, so that information would no longer be masked by the extension and hidden from the user.High-effort solution: \ Actually detecting the absence of venv at install time by parsing the
Reason
line or by sending/interpreting an alternate status code from thecheck python
step would allow the installer to handle the absence of the venv package as a separate fault with different resolution steps. This would make the code more complicated, but it would simplify the install process for people with less familiarity with Python.Error Details and Output:
In VSCode:
Developer Tools Console: