Pio : The term 'pio' is not recognized as the name of a cmdlet, function, script file, or operable program

Hello.

I am trying to develop a project on Windows 10.
I haven’t used Platformio on Windows for some time now and I can’t get it to work. I can’t run commands from the terminal, I can’t even run commands from the toolbar. It’s pretty much very broken. Please send help.

It is a fresh Platformio IDE install so everything should be up to date.

I’ve edited the system environment variable like so:


I’ve checked that folder 100 times to be sure that it exists and it does.

But I still get all these errors:

This is what’s inside platformio.ini:

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32dev
framework = arduino
board_build.flash_mode = qio
monitor_speed = 115200
build_flags = -DCORE_DEBUG_LEVEL=5
#LINUX
#upload_port = /dev/ttyUSB0
#monitor_port = /dev/ttyUSB0
#WINDOWS:
upload_port = COM
monitor_port = COM

#libraries
lib_deps =  https://github.com/me-no-dev/ESPAsyncWebServer.git
            https://github.com/me-no-dev/AsyncTCP.git
            https://github.com/marcmerlin/SmartMatrix_GFX.git
            https://github.com/marcmerlin/Framebuffer_GFX.git
            https://github.com/adafruit/Adafruit-GFX-Library.git
            https://github.com/FastLED/FastLED.git

So, what’s wrong ? Last time I’ve used it I did not have to set no environment. It worked like magic. What changed ? Why did it change ?

Thank you.

  1. Can you run pio from a normal commandline (Windows + R → cmd.exe)?
  2. Is it possible to open a PIO terminal and use pio there?

In recent VSCode extension settings, the behavior of the global shell environment of VSCode was changed to not have PlatformIO and python accessible anymore, because it may pollute existing system environments. See release page regarding 2.1.2.

Actually if you need PlatformIO globally I would suggest a global install as well. What you’re doing now by including the C:\Users\<user>\.platformio\penv\Scripts\ path is adding the path to PlatformIO’s own supposedly isolated Python installation to your whole system path – this will also conflict with existing Python installations if you have any.

The recommended way to install PlatformIO globally (if above doesn’t work), is to:

  • first do a clean uninstall of the current PlatformIO
    • uninstall the PlatformIO VSCode extension
    • back any data you may have locally modified in C:\Users\<user>\.platformio\, e.g. packages or platforms – skip if you’ve never done anything in there
    • remove the entire
  • make sure you have a systemwide halfway recent Python 3 installed (open cmd, do python3 --version; mine is 3.7.7 currently, though 3.8.x is recommended). Otherwise download Python 3.8 and check the “Add to PATH” option in the installer.
  • Install PlatformIO globally either by doing a pip3 install platformio in the cmd, or, follow the FAQ
  • Check whether the Scripts folder of you Python3 installation is in the PATH. Mine is C:\Users\<user>\AppData\Local\Programs\Python\Python37\Scripts\ and you might have to do something similiar
  • executing pio in the cmd.exe should now fully work (if not, restart the computer so that the PATH change takes effect)
3 Likes

Please remove PlatformIO from your system environment variables. It looks like you have multiple PlatformIO Cores in the system. The pio command does not work because you use a VERY OLD PlatformIO Core.

The recommended way to install PlatformIO globally (if above doesn’t work), is to:

  • first do a clean uninstall of the current PlatformIO
    • uninstall the PlatformIO VSCode extension
    • back any data you may have locally modified in C:\Users\<user>\.platformio\ , e.g. packages or platforms – skip if you’ve never done anything in there
    • remove the entire
  • make sure you have a systemwide halfway recent Python 3 installed (open cmd , do python3 --version ; mine is 3.7.7 currently, though 3.8.x is recommended). Otherwise download Python 3.8 and check the “Add to PATH” option in the installer.
  • Install PlatformIO globally either by doing a pip3 install platformio in the cmd , or, follow the FAQ
  • Check whether the Scripts folder of you Python3 installation is in the PATH. Mine is C:\Users\<user>\AppData\Local\Programs\Python\Python37\Scripts\ and you might have to do something similiar
  • executing pio in the cmd.exe should now fully work (if not, restart the computer so that the PATH change takes effect)

I did that and I can run pio in cmd and in VSC terminal.
I can also run any of the commands from the PIO toolbar.

I am trying to figure our which command is for build.
pio run -t build returns:

*** Do not know how to make File target `build' (D:\Projects\PlatformioIDE Projects\ESP_TimerOnInput-main\build).  Stop.

A normal build is just pio run. Uploading is pio run -t upload. You can list all available targets by doing a pio run --list-targets (also see pio run --help in general).

Thanks for your help!

P.S. I had this same error message with Windows 10. Even after clean install.
The file pio.exe did not exist on my hard disks after installation.
After much head scratching, it turned out that my AV (Comodo) had blocked the pio.exe file from being copied! Hope this helps someone else. Solution was just to go to AV settings and unblock that file and it was placed in the same folder as pip.exe and the other files.