# What is the proper way to use Julia Jupyter notebooks in VS Code?

**URL:** <https://discourse.julialang.org/t/what-is-the-proper-way-to-use-julia-jupyter-notebooks-in-vs-code/69925>\
**Category:** VS Code\
**Tags:** jupyter, notebooks\
**Created:** [October 17, 2021, 11:15am UTC](https://discourse.julialang.org/t/what-is-the-proper-way-to-use-julia-jupyter-notebooks-in-vs-code/69925 "2021-10-17T11:15:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugeleo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eugeleo/32/6440_2.png) [@Eugeleo](https://discourse.julialang.org/u/Eugeleo)\
**Post date:** [October 17, 2021, 11:15am UTC](https://discourse.julialang.org/t/what-is-the-proper-way-to-use-julia-jupyter-notebooks-in-vs-code/69925/1 "2021-10-17T11:15:01Z")

</div>

I tried to setup Jupyter with Julia recently, but I’ve never arrived at a perfect solution. See below for information about what I tried and what didn’t work. My questions are:

1. What Julia packages should I add to my project? (e.g. IJulia?)
2. What VS Code extensions do I need installed? (e.g. Julia (insiders?), Jupyter)
3. Which kernel should I use? (the one from Jupyter, the one from Julia extension…). Mind you, when using the one from Julia, the error messages were messed up.
4. What other things do I need to do to have proper LSP support, formatting, etc? Notably, I’d liek to have **cross-cell** autocompletion and documentation. (e.g. use VS Code insiders, select specific kernels to run the ipynb files)

* * *

What I found:

- The Jupyter extension by itself doesn’t provide any Julia LSP features like docs (understandably)
- The Julia extension by itself seems to work, but I need to select a kernel coming from my global installation of Julia, not the one installed by the extension, otherwise the errors are messed up.
- I haven’t found a way to get a function defined in one cell to be autocompleted in some other cell. Similarly, docs for my functions don’t show unless I’m writing in the cell where the functions are defined. Hopefully this is solvable.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [October 17, 2021, 12:30pm UTC](https://discourse.julialang.org/t/what-is-the-proper-way-to-use-julia-jupyter-notebooks-in-vs-code/69925/2 "2021-10-17T12:30:14Z")

</div>

1. None
2. Just the Julia extension.
3. The one from the Julia extension. What does “the error messages were messed up” mean?
4. Nothing, that’s just not properly implemented yet (each cell is treated as its own, indeptendent, document atm, but there are plans to change that, of course).

---

<div class="post-metadata">

**Author:** ![Eugeleo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eugeleo/32/6440_2.png) [@Eugeleo](https://discourse.julialang.org/u/Eugeleo)\
**Post date:** [October 17, 2021, 2:32pm UTC](https://discourse.julialang.org/t/what-is-the-proper-way-to-use-julia-jupyter-notebooks-in-vs-code/69925/3 "2021-10-17T14:32:32Z")

</div>

Thanks, this is very simple indeed.

> Each cell is treated as its own, indeptendent, document atm, but there are plans to change that, of course.

Is there an issue I could watch to track this?

> What does “the error messages were messed up” mean?

For example, running `sqrt(-1)` in the Jupyter kernel gives me:

```julia
DomainError with -1.0:
sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).

Stacktrace:
 [1] throw_complex_domainerror(f::Symbol, x::Float64)
   @ Base.Math ./math.jl:33
 [2] sqrt
   @ ./math.jl:582 [inlined]
 [3] sqrt(x::Int64)
   @ Base.Math ./math.jl:608
 [4] top-level scope
   @ In[1]:1
 [5] eval
   @ ./boot.jl:360 [inlined]
 [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1094

```

While running it in the Julia kernel fails with this error message:

```julia
Stacktrace:
  [1] throw_complex_domainerror(f::Symbol, x::Float64)
    @ Base.Math ./math.jl:33
  [2] sqrt
    @ ./math.jl:582 [inlined]
  [3] sqrt(x::Int64)
    @ Base.Math ./math.jl:608
  [4] top-level scope
    @ ~/code/ai-mgr-1/evolutionary-algorithms/eva/test.ipynb:1
  [5] eval
    @ ./boot.jl:360 [inlined]
  [6] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base ./loading.jl:1094
  [7] #invokelatest#2
    @ ./essentials.jl:708 [inlined]
  [8] invokelatest
    @ ./essentials.jl:706 [inlined]
  [9] (::VSCodeServer.var"#98#99"{VSCodeServer.NotebookRunCellArguments, String})()
    @ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/serve_notebook.jl:18
 [10] withpath(f::VSCodeServer.var"#98#99"{VSCodeServer.NotebookRunCellArguments, String}, path::String)
    @ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/repl.jl:185
 [11] notebook_runcell_request(conn::VSCodeServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, params::VSCodeServer.NotebookRunCellArguments)
    @ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/serve_notebook.jl:14
 [12] dispatch_msg(x::VSCodeServer.JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint, Base.PipeEndpoint}, dispatcher::VSCodeServer.JSONRPC.MsgDispatcher, msg::Dict{String, Any})
    @ VSCodeServer.JSONRPC ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/JSONRPC/src/typed.jl:67
 [13] serve_notebook(pipename::String; crashreporting_pipename::String)
    @ VSCodeServer ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/packages/VSCodeServer/src/serve_notebook.jl:94
 [14] top-level scope
    @ ~/.vscode-insiders/extensions/julialang.language-julia-1.4.3/scripts/notebook/notebook.jl:10
 [15] include(mod::Module, _path::String)
    @ Base ./Base.jl:386
 [16] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:285
 [17] _start()
    @ Base ./client.jl:485

```
