[英]Force Jupyter Notebook *not* to open a web browser
I'm running Jupyter notebooks (Python 3) on a remote cluster that I'm connected/tunneled to over SSH. 我正在远程集群上运行Jupyter笔记本(Python 3),我通过SSH连接/隧道连接。
Jupyter's default behavior is to try to open the dashboard in a web browser when it launches -- aparently (I only just updated), at some point they switched to the Python 3 webbrowser
library for this. Jupyter的默认行为是尝试在启动时在Web浏览器中打开仪表板 - 显然(我刚刚更新),在某些时候他们切换到Python 3 webbrowser
库。
According to webbrowser
's documentation: 根据webbrowser
的文档:
text-mode browsers will be used if graphical browsers are not available or an X11 display isn't available. 如果图形浏览器不可用或X11显示器不可用,将使用文本模式浏览器。
This is exactly what happens. 这正是发生的事情。 I run jupyter notebook
, webbrowser
launches elinks
, and my one-time authentication token gets eaten, preventing me from connecting to the notebook. 我运行jupyter notebook
, webbrowser
启动elinks
,我的一次性身份验证令牌被吃掉,阻止我连接到笔记本电脑。
Jupyter isn't configured to use a browser -- c.NotebookApp.browser
is commented out in my config -- and running BROWSER="" jupyter notebook
doesn't help either. Jupyter没有配置使用浏览器 - c.NotebookApp.browser
在我的配置中被注释掉 - 并且运行BROWSER="" jupyter notebook
也无济于事。
How can I force Jupyter not to open any browser? 我如何强迫Jupyter 不要打开任何浏览器?
jupyter-notebook --help
includes the following: jupyter-notebook --help
包括以下内容:
--no-browser
Don't open the notebook in a browser after startup.
jupyter notebook --generate-config
然后编辑〜/ .jupyter / jupyter_notebook_config.py并添加
NotebookApp.open_browser = False
You can achieve this by specifying --no-browser: 您可以通过指定--no-browser来实现此目的:
$ jupyter notebook --no-browser
I also recommend that you specify the port you want to use: 我还建议您指定要使用的端口:
jupyter notebook --no-browser --port= <port_number>
ie: 即:
$ jupyter notebook --no-browser --port=8888
You have to keep in mind that when you do this, jupyter will provide you with a token on the console, token that the server will ask you when connect remotely through the browser. 您必须记住,当您执行此操作时,jupyter将在控制台上为您提供令牌,即当通过浏览器远程连接时服务器将询问您的令牌。
If you want to simplify this procedure, you can set a password that is easier for you to remember. 如果要简化此过程,可以设置一个更易于记忆的密码。 To do this, you can run in a console: 为此,您可以在控制台中运行:
$ jupyter notebook --generate-config
and later: 然后:
$ jupyter notebook password
This last command will ask you for the password that you wish to use to enter remotely. 最后一个命令将询问您要用于远程输入的密码。
Regards! 问候!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.