In VS code I was having a similar issue and realized if I go to the shortcuts ( File > Preferences > Keyboard Shortcuts) then search Python and find "Python: Run Python File". I set the shortcut to shift + R and now I have no issues anymore with running python script. It runs the whole script and not just a select line of course, which I prefer anyway.