I ran into this exact error - turns out the problem is you need to update the Marlin source code. Doing a git pull on the branch to get the latest fixed the problem, reinstalling platformio did not. The problem is your platformio has updated at some point, but the Marlin code is using an older API.
It seems that the platformio.managers.package was removed - or at least trying to do import platformio works, import platformio.managers works, and import platformio.managers.package gives the error.
Possibly a bug in the Marlin version, but I see that Windows 10 has something to do with the problem. I have solved it by installing the Ubuntu subsystem on Windows 10 and compiling the same code but with platformio on Linux Ubuntu.
It is a problem with Marlin 2.6.0 since when updating Platformio to version 5 it gives the same error when compiling in linux as in Windows 10. I will test Marlin 2.6.1 to see if it works well and this incompatibility is solved.
Is there anything else that has to be changed in new configuration.h ?
After update I experience problem with RE-ARM board. Now when I upload firmware and connect re-arm to computer it doesn’t recognize SD card anymore and loses USB connection after couple of minutes.
I’m using Github Desktop and merged upstream into my branch, so Marlin (bugfix-2.0.x) should be updated with the latest updates as of just a few minutes ago. I’ve also tried to download both stable and bugfix from Github to my local machine and copied buildroot manually, but I still have the same error, except my missing module is ‘elftools’. I’m running PlatformIO 5.0.3. VSCode is also updated (v1.51.1). Any idea how to fix this?