Ask Your Question
2

How to get Jupyter notebook to automatically open in browser?

asked 2022-08-12 16:24:11 +0100

ChristopherChemist gravatar image

I am running SageMath 9.6 on Ubuntu 22.04.1 running using wsl2 on Windows 11. SageMath was installed from source, since a 9.6 package is not, yet, available on Ubuntu.

Previously, when version 9.5 was started with sage -n jupyter, the Jupyter notebook automatically opened a window in Firefox in Windows 11, which was pretty cool. I have reinstalled Ubuntu. On starting version 9.6 with ./sage -n jupyter, the Firefox window no longer automatically opens; I have to paste a link with a token into FireFox. How do I get the notebook to automatically open?

SageMath 9.5 seemed to be installed as a system-wide app for everyone, whereas 9.6 is installed in my user account, as recommended in the documentation. If I make 9.6 "system-wide", would the notebook then automatically open?

Thanks!

Chris

edit retag flag offensive close merge delete

Comments

ortollj gravatar imageortollj ( 2022-08-14 19:50:50 +0100 )edit

@ChristopherChemist : Did you look at the link ? does it help or not ?

ortollj gravatar imageortollj ( 2022-08-16 03:48:59 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-09-10 08:00:36 +0100

ortollj gravatar image

updated 2022-09-14 06:30:14 +0100

replace ortollj by your user name

in WSL create config file :

sage jupyter notebook --generate-config

then :

nano /home/ortollj/.sage//jupyter-4.1/jupyter_notebook_config.py

and put thes line uncommented ! no #

c.NotebookApp.use_redirect_file = False
import webbrowser
webbrowser.register('firefox', None, webbrowser.GenericBrowser(u'C:\\Program Files\\Mozilla Firefox\\firefox.exe'))
export BROWSER='/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
c.NotebookApp.browser = 'firefox'

you can change the web browser and its location to the one you prefer

[edited 2022/september 12 Mea Culpa ] in fact I just realized that apart from the line c.NotebookApp.use_redirect_file = False it is useless to add the rest of the code above in jupyter_notebook_config.py, it is in the ~/.bashrc file that you just have to add:

# ortollj added  see stackOverflow:
# https://stackoverflow.com/questions/62814002/start-this-command-cannot-be-run-due-to-the-error-the-system-cannot-find-the
# export BROWSER='/mnt/c/Program Files/Google/Chrome/Application/chrome.exe'
export BROWSER='/mnt/c/Program Files/Mozilla Firefox/firefox.exe'

as I had did several modifications to try to solve this problem I foolishly thought that it was my last modification in the jupyter_notebook_config.py file which would have been effective when in fact it was only my modification in the bashrc file ! sorry for that.

[edited 2022/09/19]

I forgot to specify that I had also done before the evolution to Ubuntu 22.04 the command: wsl.exe --update. I think with hindsight that I should not have made this evolution of WSL. In addition, the command: wsl.exe --list --verbose is not at all verbose, it responds with a simple laconic message:

wsl.exe --list --verbose
   NAME    STATE    VERSION
   Ubuntu Running    2
ortollj@DESKTOP-K30FLRP:~$
edit flag offensive delete link more

Comments

I must specify that I too had just encountered this problem launching the browser after an upgrade from ubuntu WSL 20.04 to

ortollj@DESKTOP-K30FLRP:~/.sage/jupyter-4.1$ lsb_release -a
LSB Version:    core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

previously I only had to put the line c.NotebookApp.use_redirect_file = False in jupyter_notebook_config.py

ortollj gravatar imageortollj ( 2022-09-10 08:12:13 +0100 )edit

I also specify that after upgrading to Ubuntu 22.04 SageMath 9.6 no longer worked, I had to redo a ./configure and a make -j32 .

ortollj gravatar imageortollj ( 2022-09-10 09:11:56 +0100 )edit

I had to switch to the sage-9.7.rc1 version because with sage-9.6 over Ubuntu 22.04 I encountered the error:

ImportError: libntl.so.43: cannot open shared object file: No such file or directory

when running my ipynb files. but it is ok with sage_9.7.rc1, no errors.

Something strange that I did not encounter this error when I was on Ubuntu 20.04 !

ortollj gravatar imageortollj ( 2022-09-11 09:24:32 +0100 )edit

There is still a slight problem: My sagemath shortcut on my W11 desktop no longer works since the 22.04 upgrade. I asked a question on answers.microsoft.com

ortollj gravatar imageortollj ( 2022-09-12 12:30:18 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2022-08-12 16:24:11 +0100

Seen: 1,317 times

Last updated: Sep 14 '22