5

With Python I can reuse another Jupyter notebook by importing it directly to a new one as a module (here in Anaconda) or using nbpackage.

Can this be done with Julia Jupyter notebooks? How to import functions from one notebook into another?

sophros
  • 14,672
  • 11
  • 46
  • 75

1 Answers1

6

The solution is to use NBInclude.jl package:

using NBInclude
@nbinclude("my_other_jupyter_notebook.ipynb")

This construct is analogous to having the code from notebook stored in a some.jl file and included as typical:

include("some.jl")

Please note that there are different scoping considerations at play depending on the version of Julia you use (1.0 or 0.6). Please refer to the documentation.

Installation via:

using Pkg
Pkg.add("NBInclude")

or REPL / ] (package management mode):

add NBInclude
sophros
  • 14,672
  • 11
  • 46
  • 75