# How to check if Julia is running in a vscode notebook?

**URL:** <https://discourse.julialang.org/t/how-to-check-if-julia-is-running-in-a-vscode-notebook/101863>\
**Category:** VS Code\
**Tags:** question\
**Created:** [July 21, 2023, 3:28am UTC](https://discourse.julialang.org/t/how-to-check-if-julia-is-running-in-a-vscode-notebook/101863 "2023-07-21T03:28:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenjaminDoran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benjamindoran/32/34587_2.png) [@BenjaminDoran](https://discourse.julialang.org/u/BenjaminDoran)\
**Post date:** [July 21, 2023, 3:28am UTC](https://discourse.julialang.org/t/how-to-check-if-julia-is-running-in-a-vscode-notebook/101863/1 "2023-07-21T03:28:17Z")

</div>

I’ve noticed a few issues using packages like ProgressMeter and Bio3Dview in the VS code notebook. ProgressMeter keeps appending the progress bar to new lines. [It shows repeated output in VScode · Issue #231 · timholy/ProgressMeter.jl · GitHub](https://github.com/timholy/ProgressMeter.jl/issues/231)

BioView even says that it doesn’t think it is running in a notebook context

```julia
using BioStructures
using Bio3DView
struc = retrievepdb("3LVA")
viewstruc(struc['A'])

```

output:

```julia
┌ Info: File exists: 3LVA
└ @ BioStructures /Users/ben/.julia/packages/BioStructures/1QcQI/src/pdb.jl:236
"Cannot run the command as you do not appear to be in an IJulia notebook, Blink is not loaded and html is not set to true"

```

These examples in jupterlab work as intended.

It seems like this rendering breaks down because the checks for if julia is running in a notebook returns false:

```julia
# returns false in vscode notebooks
isdefined(Main, :IJulia) && Main.IJulia.inited 

```

What would be a check for if julia is running in the VS code notebook context?

---

<div class="post-metadata">

**Author:** ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)\
**Post date:** [July 21, 2023, 1:28pm UTC](https://discourse.julialang.org/t/how-to-check-if-julia-is-running-in-a-vscode-notebook/101863/2 "2023-07-21T13:28:01Z")

</div>

What I use is

```julia
isdefined(Main, :VSCodeServer)

```

---

<div class="post-metadata">

**Author:** ![BenjaminDoran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benjamindoran/32/34587_2.png) [@BenjaminDoran](https://discourse.julialang.org/u/BenjaminDoran)\
**Post date:** [July 21, 2023, 2:48pm UTC](https://discourse.julialang.org/t/how-to-check-if-julia-is-running-in-a-vscode-notebook/101863/3 "2023-07-21T14:48:23Z")

</div>

That half works, It tells if julia is being run in VScode, but not if it is in the notebook or if it is being run in a script with output sent to the REPL.

For instance using `isdefined(Main, :VSCodeServer)` with Bio3DView, it is able to output the correct output cell in the notebook but then doesn’t work anymore in a script context, just outputting the HTML directly into the REPL rather than opening the output pane

---

<div class="post-metadata">

**Author:** ![BenjaminDoran](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benjamindoran/32/34587_2.png) [@BenjaminDoran](https://discourse.julialang.org/u/BenjaminDoran)\
**Post date:** [July 21, 2023, 5:05pm UTC](https://discourse.julialang.org/t/how-to-check-if-julia-is-running-in-a-vscode-notebook/101863/4 "2023-07-21T17:05:32Z")

</div>

`isinteractive()` seems to be what I am looking for.

```julia
is_vscode_notebook() = isdefined(Main, :VSCodeServer) && !isinteractive()

```

seems to only return true in the vscode notebook context, and not when sending code to the repl from vscode, or when running the script from the command line.
