从其他笔记本启动笔记本
Start notebook from other notebook
使用 jupyter-lab
%run otherNotebook.ipynb
给出以下错误信息
Error: file not found otherNotebook.ipynb.py
如何使用魔术方法并防止它添加 .py
到文件
如所述here %run
用于运行将IPython 中的命名文件作为程序。 Jupyter 笔记本不是 Python 程序。
可以使用 Jupytext 将笔记本转换为 Python programs/scripts。在转换之后,您可以使用 %run
.
或者,您可以使用 nbconvert to execute a notebook or use Papermill to execute a notebook. Papermill allows you to easily pass in parameters at the time of run. I have an example of both commented out in code under 'Step #5' here and 'Step#2' here。
如果您真的想将代码放入您当前的笔记本中,那么您可能想要探索 importing Jupyter notebooks as modules. importnb is recommended here for making importing notebooks more convenient. Or, I just came across the subnotebook 项目,让您 运行 一个笔记本,就像您所说的 Python 函数,传递参数并返回结果,包括输出内容。
使用 jupyter-lab
%run otherNotebook.ipynb
给出以下错误信息
Error: file not found otherNotebook.ipynb.py
如何使用魔术方法并防止它添加 .py
到文件
如所述here %run
用于运行将IPython 中的命名文件作为程序。 Jupyter 笔记本不是 Python 程序。
可以使用 Jupytext 将笔记本转换为 Python programs/scripts。在转换之后,您可以使用 %run
.
或者,您可以使用 nbconvert to execute a notebook or use Papermill to execute a notebook. Papermill allows you to easily pass in parameters at the time of run. I have an example of both commented out in code under 'Step #5' here and 'Step#2' here。
如果您真的想将代码放入您当前的笔记本中,那么您可能想要探索 importing Jupyter notebooks as modules. importnb is recommended here for making importing notebooks more convenient. Or, I just came across the subnotebook 项目,让您 运行 一个笔记本,就像您所说的 Python 函数,传递参数并返回结果,包括输出内容。