I’m running Linux Mint, which is Ubuntu based, and I sometimes see delays when running pio commands on the command line. Mostly it’s when I’m initialising a new projecgt with:
pio init -b uno
The code completes but then hangs for about 5-10 seconds before finishing the output. I always assumed that some file system syncing was going on to write down the created files to disc completely before getting back to the user to say “all done”.
Windows is a different kettle of fish.
Given that you have anti-virus and malware protection, it is going to tale longer. If you white list the PIO “stuff” then does it get any better – can you whitelist in the apps you have installed?
If you run the command a second time, immediately after the first, does it run quicker? Linux will cache recently read file system blocks, but I don;t know if Windows will do this too. No need to hit the disc again makes things quicker.
Even when whitelisted, attempting to execute the code will still be slower than if anti-virus and malware protection were completely disabled. I’m assuming (!) that there’s some kind of lookup to see if a command is whitelisted or not, before the command can be safely executed, or scanned?
I thought, at least a little while ago, that Python 3.9 caused problems when used on Windows with PlatformIO? 3.8 was advised. My Mint install is version 3.8.10. You could, if you are using VSCode as well for PlatformIO, configure VSCode to use the bundled version of Python that came with PlatformIO IDE – go to File->Preferences->Settings, serach for “builtin python” and select the option to use a portable python installation.
Also, you are not using the Python version from Windows Marketplace are you? If so, install the correct version from python.org – there are definitely problems with whatever Microsoft of offering on Marketplace.