PlatformIO Community

How to fix pio command not working?

I had errors all of a sudden when using VScode and PIO. I saw a message that told me to follow these instructions to upgrade to Python > v3.5 :

Drop support for Python 2 and 3.5
So after following these instructions I still see this issue:

> python --version
Python 3.9.1
PS D:\Users\Nurquhar\Documents\NuSoftLtd\Projects\RoutesReports\NR-MPV-SITT-RHTT-Jan2020\Software\RR-TTM-NR-release-build-trial> pio system info
pio : The term 'pio' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the 
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ pio system info
+ ~~~
    + CategoryInfo          : ObjectNotFound: (pio:String) [], CommandNotFoundException        
    + FullyQualifiedErrorId : CommandNotFoundException
 
PS D:\Users\Nurquhar\Documents\NuSoftLtd\Projects\RoutesReports\NR-MPV-SITT-RHTT-Jan2020\Software\RR-TTM-NR-release-build-trial>

So how to fix it so ‘pio’ command works ?

If you have installed PlatformIO extensions into VSCode, then you will not be able to see the pio or platformio commands in a shell outside of VSCode.

In addition, if you use VSCode’s Terminal->New Terminal option, the commands will not be available there either!

To use them, Click on the PlatformIo icon on the left side toolbar (Ant/Alien head), then in the Quick Access list that appears, under Miscellaneous, choose New Terminal.

Now you should be able to use the commands.

My best advice is to follow the instructions at https://docs.platformio.org/en/latest/core/installation.html#piocore-install-shell-commands to add the pio and platformio commands to your normal shell/command line sessions. That way, every terminal you open, inside or outside of VSCode, will have the commands available.

HTH

Cheers,
Norm.

2 Likes

Thanks Norm, now I get it …

pio system info


PlatformIO Core 5.1.0
Python 3.9.1-final.0
System Type windows_amd64
Platform Windows-10
File System Encoding utf-8
Locale Encoding cp1252
PlatformIO Core Directory C:\Users\Nurquhar.platformio
PlatformIO Core Executable C:\Users\Nurquhar.platformio\penv\Scripts\platformio.exe
Python Executable c:\users\nurquhar.platformio\penv\scripts\python.exe
Global Libraries 1
Development Platforms 6
Tools & Toolchains 19


PS D:\Users\Nurquhar\Documents\NuSoftLtd\Projects\RoutesReports\NR-MPV-SITT-RHTT-Jan2020\Software\RR-TTM-NR-release-build-trial>

1 Like

Success! :grin:

One thing though:

Some people have had problems with Python 3.9 not working correctly. If you find any problems, try using the “portable” version of Python that PlatformIO installs when you install into VSCode.

Open VSCode, then CTRL+comma. That will take you to settings. Search for “portable” and you should find one hit: “Use a portable Python 3 interpreter if available”. Tick/check the option and PlatformIO in VSCode will use the downloaded, and known to work, version of Python 3.x instead of any external versions installed outwith VSCode.

Cheers,
Norm.

Thanks for the warning…

I have a few applications that use python so when I did a search of C:\ I found I had a dozen or more copies installed in all sorts of places. So I remove via control panel all copies I thought I had installed myself. I then installed python using the windows app store, which put the 3.9.1 on my PC where ever it liked.
When I tried installing from a python a download exe platformio could not see it, it just found my python 2.7 which I have also removed. But it could see it with the version installed from the app store. I think this hassle may be related to my PC busting through the 1024 char limit for the path variable. I tried the registry hacks to increase this but it did not seem to work.
All seems to be working for me at the moment with 3.9.1 but if I get further hassle perhaps I can downgrade to 3.8 or 3.7

For PlatformIO you shouldn’t need to downgrade the system wide version on Python, just set the option I described above to use the PlatformIO built in version. I think that’s 3.6.x at the moment. The reason I’m not sure is because on my Linux system, it has sym-linked to the 3.6.7 version that is installed system wide.

Cheers,
Norm.

Norm, you are a bloody legend mate! I have been tearing my hair out trying to figure this out. Even reinstalled windows. I wish I had seen you post earlier but thanks for posting this. Cheers.

1 Like

I’m gonna buy your book.

1 Like

I try! :wink:

That’s not a mandatory requirement! But thanks. It will be handy if you want/need to know how the Arduino works. Hope you enjoy it.

Cheers,
Norm.