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

Cannot automatically open Jupyter notebook in a browser #647

Closed
strogdon opened this issue Jul 17, 2021 · 7 comments
Closed

Cannot automatically open Jupyter notebook in a browser #647

strogdon opened this issue Jul 17, 2021 · 7 comments

Comments

@strogdon
Copy link
Contributor

Tangentially related to #646. I usually don't use the notebook but tried to do so seeing #646. On one machine

$ sage -n jupyter

works as expected and a browser window is automatically opened. However, on another machine I get

$ sage -n jupyter
...
Please wait while the Sage Jupyter Notebook server starts...
[I 19:47:48.021 NotebookApp] Serving notebooks from local directory: /local/sage-git/sage
[I 19:47:48.021 NotebookApp] Jupyter Notebook 6.3.0 is running at:
[I 19:47:48.021 NotebookApp] http://localhost:8888/?token=1d4a9508a789868591fb2736faddf0607f52316b8afa2bbd
[I 19:47:48.021 NotebookApp]  or http://127.0.0.1:8888/?token=1d4a9508a789868591fb2736faddf0607f52316b8afa2bbd
[I 19:47:48.021 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 19:47:48.104 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///home/steven/.local/share/jupyter/runtime/nbserver-17329-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=1d4a9508a789868591fb2736faddf0607f52316b8afa2bbd
     or http://127.0.0.1:8888/?token=1d4a9508a789868591fb2736faddf0607f52316b8afa2bbd

A browser window is not opened. Instead the contents of file:///home/steven/.local/share/jupyter/runtime/nbserver-17329-open.html are opened in an emacs editor window. The suggested instructions do work but not automatically. So something is not set correctly. But what?

@kiwifb
Copy link
Collaborator

kiwifb commented Jul 17, 2021

Looks like a bad file association. Something in your setup has associated html files with emacs, which is not completely stupid since those are usually editable.

@strogdon
Copy link
Contributor Author

I thought maybe xdg-open was misbehaving, but not sure if the notebook calls it.

@kiwifb
Copy link
Collaborator

kiwifb commented Jul 17, 2021

I recommend inspection with xdg-mime from xdg-utils https://wiki.archlinux.org/title/Xdg-utils, I think xdg-open has to be involved somehow but it may not be in sage's code but the jupyter code.

@kiwifb
Copy link
Collaborator

kiwifb commented Jul 17, 2021

Actually it could be via dev-python/click a real deep dependency of dev-python/notebook.

@strogdon
Copy link
Contributor Author

OK, the issue

$ xdg-mime query default text/html
emacs.desktop

This should be google-chrome.desktop. I don't mess around with xdg-* so I'm not sure what set this.

$ xdg-mime default google-chrome.desktop text/html

fixes things. This must be done as a normal user. I'm not sure where it is stored.

@strogdon
Copy link
Contributor Author

I didn't see your comment relative to dev-python/click. Would that affect a normal user?

@kiwifb
Copy link
Collaborator

kiwifb commented Jul 17, 2021

The arch web page has useful indication as to where it is supposed to be stored and even how to get debug info about it.

The stuff about click is just a way to open stuff across OSes. It is not a big deal but that's one of the point where xdg-open is called. It more than affects normal users, it is probably necessary.

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

2 participants