I’m transitioning from Spyder to VS Code, and I’m having an issue executing ad-hoc code on an interactive session. I first save this to a tmp1.py and run the selection on an interactive window:
import pandas as pd
df = pd.DataFrame({'a': [1,2,3,4],
'b': [1,1,2,3]})
Then on tmp2.py I just write and run:
print(df)
It opens a new interactive window and complains NameError: name 'df' is not defined
. How can I configure it to run on the currently active window / session? Note that I’m not using a Jupyter notebook but IPython.
At some point I’ll want to run code in parallel on several terminals, but at first I’d like to get this simple set-up working.
2
Answers
For some reason my "Jupyter > Interactive Window: Creation Mode" setting was "perfile", although "multiple" is supposed to be the default. After changing it to "multiple" everything works logically. I can also open sevaral interactive windows, and the selected code gets evaluated in the active one.
Just run them in the same interactive window: