PIO Home Inspect (Check Code) of Marlin Firmware fails with "Errors: Bad JSON"

I am building a copy the bugfix-2.0.x branch of Marlin Firmware (GitHub - MarlinFirmware/Marlin: Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. | Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.) using environment STM32F103RC_btt_512K.

If I try to Inspect using Check Code, it gets about 70% of the way through before failing with the message “Errors: Bad JSON”,

How do I work out what is causing the problem? Is there a debug mode or log file for Inspect?

Probably the underlying cppcheck fails and doesn’t return any JSON output anymore.

Can you manually pio check -v in the PIO terminal and see where it fails? Might also want to redirect output to a file.

Not helpful…

Tool Manager: Installing platformio/tool-cppcheck @ ~1.210.0
Error: Could not find the package with ‘platformio/tool-cppcheck @ ~1.210.0’ requirements for your system ‘windows_x86’

I am running a 64-bit version of Windows but PIO seems to think it’s 32-bit, presumably because my system installed python is 32-bit. Uninstalling and getting a 64-bit version…

And now, when I try to build, I get…
Fatal Python error: init_sys_streams: can’t initialize sys standard streams

So… Unistall and reinstall Platformio? No change.

Maybe I’ll get back to the original problem sometime…

Hi @starnamer,

This is apparently a python bug, fixed in python 3.7 or 3.8. Details at Issue 32849: Fatal Python error: Py_Initialize: can't initialize sys standard streams - Python tracker if you are interested.

Just an FYI.

Cheers,
Norm.

I installed python-3.8.5-amd64.exe. Obviously not fixed in 3.7 or 3.8!

I’ve uninstalled and reinstalled python (twice) and uninstalled and reinstalled Platformio several times.

The error and traceback is:

Fatal Python error: init_sys_streams: can’t initialize sys standard streams
Traceback (most recent call last):
File “C:\Program Files\Python38\lib\io.py”, line 54, in
ImportError: cannot import name ‘open_code’ from ‘io’ (unknown location)

Fixed this by deleting .platformio.

Hmm. I work in IT Support myself, I hate it when something is supposedly fixed, but isn’t.

Does this mean it has installed properly now? And working?

Cheers,
Norm.

Yes. Deleting the folder .platfomio so it had to rebuild everything fixed it.

1 Like

I am facing the same issue. Please give some solution to us.
Thanks in advance,

OneVanilla

Please report a minimal example project that reproduces the problem to Issues · platformio/platformio-core · GitHub for support.

It should be fixed in the latest PlatformIO Core version. Please open PlatformIO Core CLI and type pio upgrade --dev. Restart VSCode. It should work.