正常来说在jupyter notebook 中只能调用.py文件,要想要调用jupyter notebook自己的文件会报错。
Jupyter Notebook官网介绍了一种简单的方法:
http://jupyter-notebook.readthedocs.io/en/latest/examples/Notebook/Importing%20Notebooks.html
添加jupyter notebook解析文件
首先,创建一个python文件,例如Ipynb_importer.py,代码如下:
import io, os,sys,types
from IPython import get_ipython
from nbformat import read
from IPython.core.interactiveshell import InteractiveShell
class NotebookFinder(object):
"""Module finder that locates Jupyter Notebooks"""
def __init__(self):
self.loaders = {}