PlatformIO Community

Could not initialize project - ImportError: cannot import name 'IS_WINDOWS' from 'platformio.compat'

Visual Studio Code 1.56.2
Platform IO version 2.3.2
PIO core 5.1.1
Python version 3.9.5
Windows 10 (same error on Debian 10 and Debian 11)

I initially tried to use it on Debian (Buster and Bullseye) without success and couldn’t find much in the way of clues as to what was going wrong. I Installed a windows VM, Visual Studio Code and Platform IO and everything seemed to go fine. When I try to add a new project:

Board: ST Nucleo L432KC

Framework: Ardiuno

I get the same problem I was getting on Debian:

The relevant bit appears to be

ImportError: cannot import name 'IS_WINDOWS' from 'platformio.compat'

Full errror:

PIO Core Call Error: "The current working directory C:\\Users\\James\\Documents\\PlatformIO\\Projects\\TEST will be used for the project.\r\n\r\nThe next files/directories have been created in C:\\Users\\James\\Documents\\PlatformIO\\Projects\\TEST\r\ninclude - Put project header files here\r\nlib - Put here project specific (private) libraries\r\nsrc - Put project source files here\r\nplatformio.ini - Project Configuration File\r\n\n\nError: Processing nucleo_l432kc (platform: ststm32; board: nucleo_l432kc; framework: arduino)\r\n--------------------------------------------------------------------------------\r\nVerbose mode can be enabled via `-v, --verbose` option\r\nCONFIGURATION: https://docs.platformio.org/page/boards/ststm32/nucleo_l432kc.html\r\nPLATFORM: ST STM32 (14.0.0) > ST Nucleo L432KC\r\nHARDWARE: STM32L432KCU6 80MHz, 64KB RAM, 256KB Flash\r\nDEBUG: Current (stlink) On-board (stlink) External (blackmagic, cmsis-dap, jlink)\r\nPACKAGES: \r\n - framework-arduinoststm32 4.20000.210601 (2.0.0) \r\n - framework-cmsis 2.50700.210515 (5.7.0) \r\n - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)\r\nImportError: cannot import name 'IS_WINDOWS' from 'platformio.compat' (c:\\users\\james\\.platformio\\penv\\lib\\site-packages\\platformio\\compat.py):\r\n File \"C:\\Users\\James\\.platformio\\penv\\Lib\\site-packages\\platformio\\builder\\main.py\", line 177:\r\n env.SConscript(\"$BUILD_SCRIPT\")\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Script\\SConscript.py\", line 591:\r\n return _SConscript(self.fs, *files, **subst_kw)\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Script\\SConscript.py\", line 280:\r\n exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)\r\n File \"C:\\Users\\James\\.platformio\\platforms\\ststm32\\builder\\main.py\", line 120:\r\n target_elf = env.BuildProgram()\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Util.py\", line 658:\r\n return self.method(*nargs, **kwargs)\r\n File \"C:\\Users\\James\\.platformio\\penv\\Lib\\site-packages\\platformio\\builder\\tools\\platformio.py\", line 61:\r\n env.ProcessProgramDeps()\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Util.py\", line 658:\r\n return self.method(*nargs, **kwargs)\r\n File \"C:\\Users\\James\\.platformio\\penv\\Lib\\site-packages\\platformio\\builder\\tools\\platformio.py\", line 127:\r\n env.BuildFrameworks(env.get(\"PIOFRAMEWORK\"))\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Util.py\", line 658:\r\n return self.method(*nargs, **kwargs)\r\n File \"C:\\Users\\James\\.platformio\\penv\\Lib\\site-packages\\platformio\\builder\\tools\\platformio.py\", line 342:\r\n SConscript(env.GetFrameworkScript(f), exports=\"env\")\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Script\\SConscript.py\", line 654:\r\n return method(*args, **kw)\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Script\\SConscript.py\", line 591:\r\n return _SConscript(self.fs, *files, **subst_kw)\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Script\\SConscript.py\", line 280:\r\n exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)\r\n File \"C:\\Users\\James\\.platformio\\platforms\\ststm32\\builder\\frameworks\\arduino.py\", line 50:\r\n SConscript(build_script)\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Script\\SConscript.py\", line 654:\r\n return method(*args, **kw)\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Script\\SConscript.py\", line 591:\r\n return _SConscript(self.fs, *files, **subst_kw)\r\n File \"C:\\Users\\James\\.platformio\\packages\\tool-scons\\scons-local-4.1.0\\SCons\\Script\\SConscript.py\", line 280:\r\n exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)\r\n File \"C:\\Users\\James\\.platformio\\packages\\framework-arduinoststm32\\tools\\platformio\\platformio-build.py\", line 28:\r\n from platformio.compat import IS_WINDOWS\r\n========================== [FAILED] Took 0.70 seconds ==========================

Open a CLI and execute pio upgrade --dev, then retry creating a project. Does it work now?

1 Like

Could you run pio update?

Thanks guys pio update solved it! It took me a moment to do that on windows because I don’t know my way around.

Was there a bug in the platformIO extension that caused this?

This was the output if it’s of any interest.

PS C:\Users\James\.platformio\penv\Scripts> .\pio.exe update
Updating platformio/contrib-piohome           3.3.4 @ ~3.3.4                     [Up-to-date]
Updating platformio/tool-scons                4.40100.2 @ ~4.40100.2             [Up-to-date]

Platform Manager
================
Platform ststm32
--------
Updating platformio/ststm32                   14.0.0                             [Up-to-date]
Updating platformio/toolchain-gccarmnoneeabi  1.70201.0 @ >=1.60301.0,<1.80000.0 [Up-to-date]
Updating platformio/framework-arduinoststm32  4.20000.210601 @ ~4.20000.0        [Updating to 4.20000.210602]
Tool Manager: Installing platformio/framework-arduinoststm32 @ 4.20000.210602
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: framework-arduinoststm32 @ 4.20000.210602 has been installed!
Tool Manager: Removing framework-arduinoststm32 @ 4.20000.210601
Tool Manager: framework-arduinoststm32 @ 4.20000.210601 has been removed!