Open IPython notebooks (*.ipynb) in read-only view (like a HTML file)

前端 未结 7 1576
旧巷少年郎
旧巷少年郎 2021-01-31 17:13

Nowadays with more and more IPython notebook files (*.ipynb) around, it is very disturbing every time when I want to peek at some notebook I have to open a server for it, and ca

7条回答
  •  甜味超标
    2021-01-31 18:03

    The best I can suggest - unfortunately still a bit verbose - is using nbconvert to create a HTML version of the file, then opening it with your browser. Below are commands to do this (assuming that your browser is set up as the default program to handle .html files). Just replace yournotebook.ipynb with your real Notebook name.

    Linux
    jupyter nbconvert --to html yournotebook.ipynb --output /tmp/notebook.html &&
    xdg-open /tmp/notebook.html
    
    macOS
    jupyter nbconvert --to html yournotebook.ipynb --output /tmp/notebook.html &&
    open /tmp/notebook.html
    

    Windows
    jupyter nbconvert --to html yournotebook.ipynb --output "%TEMP%\notebook.html" && start "" "%TEMP%\notebook.html"
    

    (Note that if you want to do this in bulk, perhaps in a loop in a script, you'll probably want to modify the commands above to not always use the same filename for the HTML file, to avoid the race condition where the HTML file has been overwritten by the time the browser actually gets round to starting to read it.)

提交回复
热议问题