问题
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/firefoxfor Linux (see here)/Applications/Firefox.app/Contents/MacOS/firefoxfor macOS (see this)C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exefor 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