Hey! Hope this helps others who had the same issue. I solved it by checking setting "Execute In File Dir".
The problem was this: when running a python file which is not directly in the workspace directory but somewhere in a deeper folder, if this file had to load data from some other folder residing somewhere else in the hieararchy, file paths had to be different, when running as code, or as notebook (pressing Shift+Enter to run in an interactive window).
Specifically, my file was placed here:
/myproject/src/visualization/viz.py And the data was here:
/myproject/data/external/clientdata.xlsx
When running "viz.py" in the interactive notebook by pressing Shift+Enter, I had to use this path: "../../data/external/clientdata.xlsx"
because I had to go two folders up and then two folders down to the data, and I had to do so, because my current working directory was in folder "visualization"
But when running "viz.py" as code (pressing the Run button), this path no longer worked, because the code was running from the workspace folder "myproject". So I had to change the path to: "data/external/clientdata.xlsx"
For a while, I simply put both paths in variables, and when executing in code, I would comment out one of them, while for running as a notebook, I would comment out the other one.
Then I found how to change the current working directory of VS Code by turning on this setting:
Python > Terminal: Execute In File Dir
Now my file is always executed from the same current working directory, so file paths are the same, whether I am running normally, or with Shift+Enter -> interactive window.
Hope that helps!
Or perhaps someone has a better solution?