In VSCode, a script with:
#%%
a = 3
creates a Jupyter cell. Running the cell starts Jupyter server and evaluates the code in Python Interactive window.
I would like to interact with this session and pass print(a)
to it from a console, without modifying the Jupyter notebook. Is that possible? I cannot find a way to open a Python session in which a
would be defined.
I'd suggest logging a suggestion from our GitHub: https://github.com/Microsoft/vscode-python/issues
This might be similar to what you're asking for. https://github.com/Microsoft/vscode-python/issues/3101
This would allow you to type temporary code into the interactive window. If you didn't like it, you could delete it.
You could call ipython's %qtconsole
magic command
#%%
%qtconsole
This opens up a separate jupyter qt-console window which points at the same kernel as the vbcode 'notebook'.
This works for me (Windows 10):
conda install qtconsole
pip install PyQt6
ipython qtconsole
. . . 6. then you can do your experiments onto the existing.ipynb notebook.
Jupyter Lab is much much better. You can open any.py and select an existing.ipynb as its kernel. Then highlight anything on the.py and press Shift-Enter to execute the highlight. I have a.py that collects most useful code snippets and it keeps everything I tried. Why VS code can't do this? Or it can actually already?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.