Failed to write .bat file for launching jupyter lab (jupyter notebook)

Viewed 81

I often use jupyterlab on my Windows 10 PC and I always launch it by typing

> julia
> using IJulia
> jupyterlab()

on a command-prompt.

It is bothersome typing this every time I use it, so I tried writing .bat file to automate this process like below:

[jupyterlab.bat]

echo "launching jupyterlab..."
julia
using IJulia
jupyterlab()
end

However, this command line stops when Julia launched, that mean cmd does not read using IJulia and jupyterlab().

Why does this happen and how can I get through it?

Any information would be appreciated.

2 Answers

Once julia is executed, you're no longer in command-line of Windows anymore. For example, using IJulia is intended to be typed into Julia REPL, not Windows command-line. The easier way is to pass the commands into Julia directly, try having this in your .bat file:

julia -e "using IJulia; jupyterlab()"

The -e (and other options) is explained here: https://docs.julialang.org/en/v1/manual/command-line-options/#command-line-options

The *.bat command is execute in Windows command line that accepts only Windows commands not Julia commands and you have mixed both of them.

Rather than that you should use the -e parameter available when launching Julia.

Hence your *.bat file could be:

echo "launching jupyterlab..."
julia -e "using IJulia;jupyterlab()"
Related