Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I launch Jupyter Notebook in WSL using PowerShell?

What I want to do is to create a shortcut for Jupyter Notebook which has to run in WSL (because all my python packages are there). For this AFAIK I should create PowerShell script which runs WSL with command to launch Jupyter Notebook, something like this:

wsl -e bash -c "jupyter notebook"

But this command gives bash: jupyter: command not found although if I do it step by step, it launches Jupyter:

PS C:\Users\Artem> wsl
(base) artem@LAPTOP-O4C3S1UK:/mnt/c/Users/Artem$ jupyter notebook

All tested commands suffer from one of these problems:

  1. bash cannot find the command (neither jupyter or anaconda)
  2. Some terminal laucnhes and instantly disappears

I am not proficient enough in PowerShell/WSL scripting so asking for advice how to do it properly.

P.S. I guess I can install jupyter for Windows and add kernels from WSL, but I want to know if problem can be solved in the way described above.

like image 488
QuadR Avatar asked Dec 17 '25 19:12

QuadR


1 Answers

It sounds like required initializations are performed in your ~/.bashrc file, which bash by default only loads in interactive sessions, not when you submit a command to execute with -c.

However, you can explicitly tell bash to consider a session interactive, using the -i option.

Therefore, try the following (note the -i):

wsl -e bash -ic "jupyter notebook"
like image 115
mklement0 Avatar answered Dec 20 '25 10:12

mklement0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!