I spent quite a lot of time solving the problem with %matplotlib widget
on VSCode. When trying to go to interactive mode, the kernel was hanging and preventing further execution. The solution was very simple - always run VSCode as administrator. I hope this will help someone a lot.