Using Jupyter with Windows Subsystem for Linux

前端 未结 4 1145
情深已故
情深已故 2021-02-13 20:56

Using the Ubuntu bash terminal on Windows 10 (installation instructions here), I installed Anaconda and have been using Jupyter notebooks without a problem. Unfortunately, Jupyt

相关标签:
4条回答
  • 2021-02-13 21:19

    I had similar issue with browser, I got

    No web browser found: could not locate runnable browser.
    

    I installed WSLU https://github.com/wslutilities/wslu. Then I got

    Start : This command cannot be run due to the error: The system cannot find the file specified.
    At line:1 char:1
    + Start --h
    + ~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    

    jupyter-notebook does not supply url as a parameter to wlsview. It passes a path with file to browser. eg

    file:///home/myhome/.local/share/jupyter/runtime/nbserver-5058-open.html
    

    with actual url

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="1;url=http://localhost:8888/tree?token=19b5f1fefb13f5fc315b05991175d1f8cb5ada9baaca6804" />
        <title>Opening Jupyter Notebook</title>
    </head>
    <body>
    
    <p>
        This page should redirect you to Jupyter Notebook. If it doesn't,
        <a href="http://localhost:8888/tree?token=19b5f1fefb13f5fc315b05991175d1f8cb5ada9baaca6804">click here to go to Jupyter</a>.
    </p>
    
    </body>
    </html>
    

    Create a file jupyter-notebook-browser with a content to extract actual url

    #!/bin/bash
    file=$(echo "$1" | sed 's/file:\/\///')
    url=$(grep -oP 'href="\K([^"]*localhost[^"]+)' "$file")
    wslview "$url"
    

    then run jupyter-notebook --browser=jupyter-notebook-browser

    or define BROWSER variable and run

    export BROWSER="jupyter-notebook-browser"
    jupyter-notebook
    
    0 讨论(0)
  • 2021-02-13 21:20

    I had the problem that Jupyter didn't find a file (complete error message in German):

    Start : Dieser Befehl kann aufgrund des folgenden Fehlers nicht ausgeführt werden: Das System kann die angegebene
    Datei nicht finden.
    In Zeile:1 Zeichen:1
    + Start "file:///home/nico/.local/share/jupyter/runtime/nbserver-1164-o ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
        + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand
    

    Jupyter did work, but it didn't open my browser, when I typed jupyter notebook.

    I found a very simple solution to this:

    1. Create the Jupyter Config file:
    touch $HOME/.jupyter/jupyter_notebook_config.py
    
    1. Now add the following line (by using nano or any other text editor):
    c.NotebookApp.use_redirect_file = False
    

    Now my WSL2 uses the wslview command to open the default browser in Windows. (I think)

    If wslview . does nothing, you might need to manually install wslu.

    0 讨论(0)
  • 2021-02-13 21:26

    Assign different port number manually when you start the notebook. For example:

    jupyter notebook --port=8889

    0 讨论(0)
  • 2021-02-13 21:30

    try:

    jupyter notebook --no-browser
    
    0 讨论(0)
提交回复
热议问题