For some reason, I returned from Mac to Windows (second time), and when I ran jupyter notebook
on WSL in the same way as Mac, I encountered an event that the browser did not start automatically, so I will explain how to deal with it.
It may not be enough to introduce it again, but I could not find any information in Japanese even if I googled with the error message, so I will expose it here.
After installing jupyter with pip install
, when I run jupyter notebook
, the following error is displayed and it does not start automatically in the browser.
$ jupyter notebook
[I 01:39:20.094 NotebookApp] Serving notebooks from local directory: /mnt/c/workspace
[I 01:39:20.094 NotebookApp] The Jupyter Notebook is running at:
[I 01:39:20.094 NotebookApp] http://localhost:8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[I 01:39:20.095 NotebookApp] or http://127.0.0.1:8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[I 01:39:20.095 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 01:39:20.116 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/wsluser/.local/share/jupyter/runtime/nbserver-xxxx-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
or http://127.0.0.1:8888/?token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Start : This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:1
+ Start "file:///home/wsluser/.local/share/jupyter/runtime/nbserver-xx ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
It seems to occur because the path of nbserver-xxxx-open.html on WSL cannot be referenced from the browser (Windows) side, but it starts when jumping to the URL of http: // localhost: 8888 /? Token = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I will.
Execute with --NotebookApp.use_redirect_file = False
.
$ jupyter notebook --NotebookApp.use_redirect_file=False
It is troublesome to specify the option every time, so set an alias appropriately and execute it.
$ echo "alias jn='jupyter notebook --NotebookApp.use_redirect_file=False'" >> ~/.bashrc
$ source ~/.bashrc
$ jn
Run with --generate-config
and set c.NotebookApp.use_redirect_file = False
in the generated config file. Then run without options.
//Generate config
$ jupyter notebook --generate-config
Writing default config to: /home/wsluser/.jupyter/jupyter_notebook_config.py
//Check the default settings
$ grep use_redirect_file ~/.jupyter/jupyter_notebook_config.py
#c.NotebookApp.use_redirect_file = True
//Uncomment and change to False
$ sed -i -e 's/#c.NotebookApp.use_redirect_file = True/c.NotebookApp.use_redirect_file = False/g' ~/.jupyter/jupyter_notebook_config.py
//Check the changed settings
$ grep use_redirect_file ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.use_redirect_file = False
//Run without options
$ jupyter notebook
Recommended Posts