Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open_browser=False doesn't work anymore #145

Closed
thorstenkampe opened this issue Dec 24, 2020 · 14 comments
Closed

open_browser=False doesn't work anymore #145

thorstenkampe opened this issue Dec 24, 2020 · 14 comments

Comments

@thorstenkampe
Copy link

thorstenkampe commented Dec 24, 2020

Up until the new version 3 c.LabApp.open_browser = False used to work when starting jupyter-lab. The setting is now c.ServerApp.open_browser and it defaults to False but a browser window is opened every time I start jupyter-lab.

@Zsailer
Copy link
Member

Zsailer commented Dec 25, 2020

This seems to be working for me.

The following commands:

jupyter lab --no-browser
jupyter lab --ServerApp.open_browser=False

both prevent a browser from opening.

Further, using the c.ServerApp.open_browser=False in a config file prevents the browser from opening.

What, exactly, are you calling on your command line?

@thorstenkampe
Copy link
Author

Specifying "no browser" on the command line as above works for me - although according to a newly generated default configuration this should not be necessary because false is now the default.

echo 'c.ServerApp.open_browser = False' > test_config.py
jupyter-lab --config test_config.py

...opens the browser.

> conda list jupyter
# packages in environment at F:\scoop\apps\miniconda3\current\envs\main:
#
# Name                    Version                   Build  Channel
jupyter_client            6.1.7                      py_0    conda-forge
jupyter_core              4.7.0            py39hcbf5309_0    conda-forge
jupyter_server            1.1.3            py39hcbf5309_0    conda-forge
jupyterlab                3.0.0              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_server         2.0.0              pyhd8ed1ab_0    conda-forge

@thorstenkampe
Copy link
Author

Using c.LabApp.open_browser instead of c.ServerApp.open_browser works (browser not opened):

[W 2020-12-25 08:13:02.023 LabApp] 'open_browser' has moved from LabApp to ServerApp. Be sure to update your config before our next release.

@thorstenkampe
Copy link
Author

If I put c.LabApp.open_browser = False in my default configuration file (jupyter_lab_config.py, used to be jupyter_notebook_config.py), the browser opens incorrectly. If I specify the config file via --config, the browser does not open. The log to the console shows the config file is read twice (once as default and next via --config).

Conclusion:

  • ServerApp.open_browser does not work in a config file
  • LabApp.open_browser does work in a config file - but only if directly specified via --config

@thorstenkampe
Copy link
Author

The strange thing is that none of the above should actually matter if the generated default configuration is true about open_browser defaulting to False (used to be True pre jupyterlab v3).

@jph00
Copy link

jph00 commented Jan 5, 2021

Confirming what @thorstenkampe says: it only works if --config is specified, and furthermore is LabApp is used (which then gives a warning to use ServerApp, but ServerApp doesn't work.

@jph00
Copy link

jph00 commented Jan 5, 2021

cc @willingc
(Carol please let me know if this is an appropriate thing to at-mention you about :) )

@jasongrout
Copy link
Contributor

It does seem like Jupyter Server defaults to open_browser being False: https://github.com/jupyter-server/jupyter_server/blob/60c66b6a1ce26c474efae8bb8e77de621a58272c/jupyter_server/serverapp.py#L890

That seems odd to me. @Zsailer, do you happen to know what is going on there?

@jasongrout
Copy link
Contributor

@jasongrout
Copy link
Contributor

@blink1073
Copy link
Contributor

Work in progress: jupyter-server/jupyter_server#375

@Zsailer
Copy link
Member

Zsailer commented Jan 7, 2021

Things should be better now by upgrading jupyter_server, i.e. pip install -U jupyter_server.

You'll temporarily get a warning that looks like:

'open_browser' is found in LabApp, NotebookApp, and ServerApp. This is a recent change.This config will only be set in LabApp. Please check if you should also config these traits in NotebookApp and ServerApp for your purpose.

until nbclassic handles this trait.

@Zsailer
Copy link
Member

Zsailer commented Jan 21, 2021

Update nbclassic to nbclassic>=0.2.6 to drop the unnecessary warning above.

With jupyter_server>=1.2.1 and nbclassic>=0.2.6, open_browser should work as expected. Closing this issue, but please reopen if the issue persists!

Thanks, all!

@Zsailer Zsailer closed this as completed Jan 21, 2021
@JohnPaton
Copy link

JohnPaton commented Feb 19, 2021

I'm encountering this issue now. I'm not able to start jupyter lab in a headless environment despite having open_browser=False in my config files:

$ pip freeze | grep jupy
jupyter-client==6.1.11
jupyter-core==4.7.1
jupyter-resource-usage==0.5.1
jupyter-server==1.4.0
jupyterlab==3.0.8
jupyterlab-pygments==0.1.2
jupyterlab-server==2.2.1
jupytext==1.10.2

$ cat ~/.jupyter/jupyter_server_config.py | grep browser
c.NotebookApp.open_browser = False
c.ServerApp.open_browser = False

$ jupyter lab
[I 2021-02-19 10:17:11.664 ServerApp] jupyter_resource_usage | extension was successfully linked.
[W 2021-02-19 10:17:11.672 LabApp] 'token' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.672 LabApp] 'password' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.672 LabApp] 'password' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.672 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.672 LabApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.672 LabApp] 'ip' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.672 LabApp] 'allow_origin_pat' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.673 LabApp] 'allow_remote_access' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.673 LabApp] 'disable_check_xsrf' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.673 LabApp] 'base_url' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2021-02-19 10:17:11.682 ServerApp] jupyterlab | extension was successfully linked.
[I 2021-02-19 10:17:11.682 ServerApp] jupytext | extension was successfully linked.
[W 2021-02-19 10:17:11.686 NotebookApp] 'token' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.686 NotebookApp] 'password' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.686 NotebookApp] 'password' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.687 NotebookApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.687 NotebookApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.687 NotebookApp] 'ip' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.687 NotebookApp] 'allow_origin_pat' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.687 NotebookApp] 'allow_remote_access' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.687 NotebookApp] 'disable_check_xsrf' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-02-19 10:17:11.687 NotebookApp] 'base_url' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2021-02-19 10:17:11.971 ServerApp] nbresuse | extension was found and enabled by nbclassic. Consider moving the extension to Jupyter Server's extension paths.
[I 2021-02-19 10:17:11.971 ServerApp] nbresuse | extension was successfully linked.
[I 2021-02-19 10:17:11.971 ServerApp] nbclassic | extension was successfully linked.
[W 2021-02-19 10:17:11.990 ServerApp] All authentication is disabled.  Anyone who can connect to this server will be able to run code.
[I 2021-02-19 10:17:11.994 ServerApp] jupyter_resource_usage | extension was successfully loaded.
[I 2021-02-19 10:17:11.995 LabApp] JupyterLab extension loaded from /usr/local/lib/python3.7/site-packages/jupyterlab
[I 2021-02-19 10:17:11.995 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 2021-02-19 10:17:11.999 ServerApp] jupyterlab | extension was successfully loaded.
[I 2021-02-19 10:17:11.999 ServerApp] [Jupytext Server Extension] Deriving a JupytextContentsManager from LargeFileManager
[I 2021-02-19 10:17:12.001 ServerApp] jupytext | extension was successfully loaded.
[I 2021-02-19 10:17:12.006 ServerApp] nbclassic | extension was successfully loaded.
[W 2021-02-19 10:17:12.006 ServerApp] nbresuse | extension failed loading with message: Duplicated timeseries in CollectorRegistry: {'total_memory_usage'}
[I 2021-02-19 10:17:12.006 ServerApp] Serving notebooks from local directory: /some/directory
[I 2021-02-19 10:17:12.007 ServerApp] Jupyter Server 1.4.0 is running at:
[I 2021-02-19 10:17:12.007 ServerApp] http://localhost:8080/lab
[I 2021-02-19 10:17:12.007 ServerApp]  or http://127.0.0.1:8080/lab
[I 2021-02-19 10:17:12.007 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/jupyter_server/serverapp.py", line 2018, in launch_browser
    browser = webbrowser.get(self.browser or None)
  File "/usr/local/lib/python3.7/webbrowser.py", line 65, in get
    raise Error("could not locate runnable browser")
webbrowser.Error: could not locate runnable browser

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/jupyter-lab", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/jupyter_server/extension/application.py", line 520, in launch_instance
    serverapp.start()
  File "/usr/local/lib/python3.7/site-packages/jupyter_server/serverapp.py", line 2100, in start
    self.start_app()
  File "/usr/local/lib/python3.7/site-packages/jupyter_server/serverapp.py", line 2059, in start_app
    self.launch_browser()
  File "/usr/local/lib/python3.7/site-packages/jupyter_server/serverapp.py", line 2020, in launch_browser
    self.log.warning(_('No web browser found: %s.') % e)
UnboundLocalError: local variable '_' referenced before assignment

Note that I have the properties duplicated over c.NotebookApp and c.ServerApp because this config file is being used for different jupyter versions, but I don't think that should matter.

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants