sophros
sophros

Reputation: 16738

Calling a julia function from jupyter notebook (import Julia jupyter notebook)

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?

Upvotes: 6

Views: 1716

Answers (1)

sophros
sophros

Reputation: 16738

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

Upvotes: 6

Related Questions