import pickle import nbformat with open('/code/webpanel_ntbk.ipynb', 'r') as f: notebook = nbformat.read(f, nbformat.NO_CONVERT); with open('/code/notebook.pkl', 'wb') as f: pickle.dump(notebook, f) #with open('/code/webpanel_ntbk.py', 'w') as fw: # fw.write(repr(app))