Python 3.x Jupyter笔记本以编程方式运行单元格

Python 3.x Jupyter笔记本以编程方式运行单元格,python-3.x,jupyter-notebook,Python 3.x,Jupyter Notebook,我已经为第一个单元格的输出中的每个单元格创建了ipywidget按钮。我想在单击按钮时运行单元格 显示(Javascript('IPython.notebook.execute_cells_below()'))。这很好用。但是当它试图使用单元索引运行特定的单元时,什么都没有发生 有没有办法为每个单元格指定固定索引 # cell 1 from IPython.display import Javascript, display from ipywidgets import widgets def

我已经为第一个单元格的输出中的每个单元格创建了ipywidget按钮。我想在单击按钮时运行单元格

显示(Javascript('IPython.notebook.execute_cells_below()'))。这很好用。但是当它试图使用单元索引运行特定的单元时,什么都没有发生

有没有办法为每个单元格指定固定索引

# cell 1
from IPython.display import Javascript, display
from ipywidgets import widgets

def run_all(ev):
    display(Javascript('IPython.notebook.execute_cells_below()'))
    #display(Javascript('IPython.notebook.execute_cells(3)'))

button = widgets.Button(description="Create next input")
button.on_click(run_all)
display(button)

#cell 2
print('hi from cell 2')

#cell 3
print('hi from cell 3')