Run jupyter notebook in incognito window

五迷三道 提交于 2019-12-11 00:47:26

问题


On executing the command jupyter notebook, notebook opens on Mozilla Firefox.

How to open notebook on incognito mode of Mozilla Firefox from command line?


回答1:


Typically Jupyer opens on http://localhost:8888 all you need to do is copy that url and open it yourself in an incognito Firefox session.




回答2:


In your config add the following to set the default browser to a private firefox (adapted from here and parameters from there):

jupyter_notebook_config.py
[...]
## Specify what command to use to invoke a web browser when opening the notebook.
#  If not specified, the default browser will be determined by the `webbrowser`
#  standard library module, which allows setting of the BROWSER environment
#  variable to override it.
import webbrowser
webbrowser.register('private_firefox', None, webbrowser.get('"' + 'path/to/firefox' +'" -private %s'))
c.NotebookApp.browser = 'private_firefox'
[...]

where path/to/firefox would be something like one of these

  • /usr/bin/firefox for Linux (see here)
  • /Applications/Firefox.app/Contents/MacOS/firefox for macOS (see this)
  • C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe for Windows (as described here)

note:
Other browsers like Chrome ("...\\chrome.exe" --incognitoas in the source) would work analogously, I suppose. I have not tested others. Feel free to comment, if there are any hurdles.



来源:https://stackoverflow.com/questions/48787973/run-jupyter-notebook-in-incognito-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!