[FIXED] Programmatically Execute Cell Jupyter VSCode

Issue

I am looking for a way to programmatically replicate the Run Cell Below functionality VS code.

Previously, I used Jupyter through Conda and used the following code:

import ipywidgets as widgets
from IPython.display import display,Markdown,Javascript,HTML

def run_below(ev):
    Javascript('IPython.notebook.execute_cells_below()')
    
button = widgets.Button(description="Click to run cells below")
button.on_click(run_below)
display(button)

This code worked great, but when I tried to plop it into VSCode, the button just does nothing. I don't understand much about how the VSCode Jupyter backend works, but I'm imagining it has something do do with the IPython.notebook module not working correctly in this IDE (or perhaps the IPython.display.Javascript module?). I really have no real idea though.

Does anyone know how I could do this in VSCode's Jupyter implementation?

I have searched for hours on this topic, but have not been able to find a working solution that works. Please let me know if y'all have any ideas.

Environment Info:

Python Version: 3.9.12
VSCode Version: 1.69.0
Jupyter Extension Version: v2022.6.1001902341


Solution

It appears that the ability to access the Kernel in VS code is not possible at this time. See the following GitHub issues to see if this has changed at the time of reading:

Similar question migrated to #6918

Issue #6918 that will resolve problem once closed



Answered By - Brian Keith
Answer Checked By - Gilberto Lyons (Python.Easybugfix Admin)

Related Posts

Post a Comment