PlatformIO IDE doesn't see Python3-venv on Linux

Whenever I try to install PlatfromIO IDE on VS Code in Linux Mint I get this error:

Error: Error: Can not install PlatformIO Core due to a missed venv module in your Python installation. Please install this package manually using the OS package manager. For example: $ apt-get install python3-venv (MAY require administrator access sudo) → Installer version: 1.2.0 Platform: Linux-5.15.0-76-generic-x86_64-with-glibc2.35 Python version: 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] Python path: /usr/bin/python3 Creating a virtual environment at /home/joshindigo/.platformio/penv at /home/joshindigo/.vscode/extensions/platformio.platformio-ide-3.3.0-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:5300 at ChildProcess.i (/home/joshindigo/.vscode/exten…

I already have python3-vevn installed so I’m unsure as to what the issue would be.

Do you have multiple Python versions intalled? (sudo dpkg -i | grep python)

Could you open system terminal and type:

python3 -m ensurepip --help
python3 -m venv --help

Do these command work?

P.S.: See also

I am also facing this issue. I am using Linux Mint 21.2. I have multiple version of python installed. As mentioned in previous comment, both ensurepip and venv commands are working.

Yes both help commands work. So far it looks like I may have fixed the problem by reinstalling VSCode using a flatpack but now I need to see if the extension is able to run correctly.

Yes. So far I’ve managed to get the extension to install by reinstalling VSCode with a flatpack but now I need to see if the extension can run tasks such as building and uploading normally.

Ok, my solution was to reinstall VSCode as a flatpak from flathub and that seems to have fixed the issue. Extension seems to run fine.

Hmmm. I’ve been using PlatformIO for ages, and today, in VSCode, it decided to upadate as it has done previously with no problems.

After a while I get a message “PlatformIO cannot find a working Python3.6+ interpreter. Please install the latest Python 3 and restart VSCode.”.

I check, python --version which returns 3.10.6. Seems fine. whereis python returns /usr/bin/python.

I’m offered a button, “I have python” so I click it and type in /usr/bin/python when prompted. After a pause, we go back to the start saying there’s no python. If I ignore the popup it vanishes and the Platform IO update hangs.

I haven’t updated Python recently. VSCode updated a week ago, it seems from this:

Version: 1.80.1
Commit: 74f6148eb9ea00507ec113ec51c489d6ffb4b771
Date: 2023-07-12T17:22:25.257Z
Electron: 22.3.14
ElectronBuildId: 21893604
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Linux x64 6.2.0-25-generic

I wonder if the problem is in VSCode or PlatformIO. Any clues as to where I can look?

On the command line, which is working fine, pio --version returns PlatformIO Core, version 6.1.9.

Cheers,
Norm.

PS. Flatpack is not an option for me.

Does this command work for you?

python3 -c '__import__("ensurepip"); __import__("venv")'

Ah! If only I’d scrolled back in this thread. My bad.

It seems I have no module named “ensurepip”:

ModuleNotFoundError: No module named 'ensurepip'

I do appear to have venv though but I don’t use it. At least, unless PlatformIO uses it under the covers. :wink:

python3 -m venv --help
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear] [--upgrade]
            [--without-pip] [--prompt PROMPT] [--upgrade-deps]
            ENV_DIR [ENV_DIR ...]

Creates virtual Python environments in one or more target directories.

However, I needed to do this to actually get ensurepip to respond:

python3 --version
Python 3.10.6

apt search python3.10 | grep -e venv -e ensurepip

p   python3.10-venv                           - Interactive high-level object-oriented language (pyv
p   python3.10-venv:i386                      - Interactive high-level object-oriented language (pyv
v   python3.10-venv:any                       -  

This showed that python3.10-venv:any was not installed. I installed it with:

sudo apt install python3.10-venv

And after that, I get this:

python3 -m ensurepip --help
usage: python -m ensurepip [-h] [--version] [-v] [-U] [--user] [--root ROOT] [--altinstall]
                           [--default-pip]

And, on opening VSCode, the upgrade finishes. It looks like Linux MInt (Ubuntu and/or Debian also perhaps?) need to install the package python3.xx-venv in order to get the latest PlatformIO to install.

HTH

Cheers,
Norm.

Hi, normandur,

I know this is topic is closed, but this maybe helpful…

Im running Linux Mint 22 (wilma )
I had exactly the same error and typed the same. Finally I got this this from my Terminal

home$python3 -m ensurepip
ensurepip is disabled in Debian/Ubuntu for the system python.

Python modules for the system python are usually handled by dpkg and apt-get.

apt install python3-<module name>

Install the python3-pip package to use pip itself. Using pip together
with the system python might have unexpected results for any system installed
module, so use it on your own risk, or make sure to only use it in virtual
environments.

( I had installed pip previously )

home$apt install python3-pip
Leyendo lista de paquetes… Hecho
Creando árbol de dependencias… Hecho
Leyendo la información de estado… Hecho
python3-pip ya está en su versión más reciente (24.0+dfsg-1ubuntu1.3).
0 actualizados, 0 nuevos se instalarán, 0 para eliminar y 77 no actualizados.

So finally I tried this

home$sudo snap install --classic code

and thats all. When I start VS Im asked for a superuser root, but this is a minor fault

Now PlatformIo is running perfectly

yours

Morning,

when I had problems I was missing one package. Installing it fixed my problem and prevented me from having to use a flat pack version of VSCode!

sudo apt install python3.10-venv

If I remember, the problem is down to ensurepip being disabled for use with the system wide python, hence the need for venv, to allow its use.

Cheers,

Norm.