Ask Your Question

Change SageMath Notebook browser

asked 2021-09-25 13:58:00 +0200

TitoYisus gravatar image

When I open SageMath Notebook it opens an Opera tab with the Jupyter home folder, but I want it to open another browser's (Chrome) tab. Setting Chrome as the default browser is not an option, I want to keep Opera.

I was able to do this with Python by generating a config file and changing the app's default browser, but I can't find any information on how to do this in with SageMath. I use Windows 10, in case that makes any difference in the process.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-09-26 04:58:14 +0200

dsejas gravatar image

Hello, @TitoYisus! I had success with the following procedure. Unfortunately, I only have Linux installed in my computer, so I am not 100% sure if this will work in Windows (although, in principle, it should). If it indeed solves your problem, please, let me know.

First, you should tell Jupyter to create a configuration file. In the case of Sage, you do this by executing

sage -n jupyter --generate-config

The --generate-config option is passed to Jupyter, so it creates its configuration file. Alternatively, you can also run

sage --python -m jupyter notebook --generate-config

The --python option tells sage to run its Python interpreter. Then, the -m option is passed to that Python interpreter, which tells it what module to execute. We specify the jupyter module with the notebook option. (Note: In the case of Windows, I imagine you should run any of these commands in the shell program that gets install with Sage.)

As far as my experience goes, this should print a message indicating where the configuration file was created. In my case (Linux), the message said

Writing default config to: ~/.sage//jupyter-4.1/

Then, you simply open that file and locate the line that says

c.NotebookApp.browser = ''

Uncomment it and put inside the quotation marks the browser of your preference (chrome in your case). That should do the trick!

A simpler alternative is to specify the browser with the command

sage -n jupyter --browser=chrome

This is a non-presistent configuration option, so you should execute this line every time you run Jupyter.

I hope this helps!

edit flag offensive delete link more


Hi, @dsejas

Thank you, but I tried both of your solutions, but neither worked. I always get this error message:

[W 23:50:12.505 NotebookApp] No web browser found: could not locate runnable browser.

I found another solution out there: in

c.NotebookApp.browser = ' '

write inside the quotation marks the path to chrome.exe. This showed no error, only if wrting "%s" at the end:

'path/to/your/chrome.exe %s'

but didn't open any browser, it only gave me the url.

Alternatively, I tried the solution that worked for me with the anaconda notebooks:

import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser('C:\Program Files\Google\Chrome\Application\chrome.exe'))
c.NotebookApp.browser = 'chrome'

but it didn't work.

I hope I can get this somehow.

TitoYisus gravatar imageTitoYisus ( 2021-10-06 00:11:59 +0200 )edit

Forgot to comment: when trying the last solution, it opens Opera (my default browser), whereas the ones before that one didn't open any browser at all. I can work with Opera, but I have all my "study/work" stuff in Chrome and my personal stuff in Opera, that's why I would like to change the browser.

TitoYisus gravatar imageTitoYisus ( 2021-10-06 00:21:33 +0200 )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


Asked: 2021-09-25 13:58:00 +0200

Seen: 64 times

Last updated: Sep 26