notebook: execution error: doesn’t understand the “open location” message. (-1708)

This error message appeared randomly today when I (as usually) tried to start a notebook via jupyter notebook

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 107
  • Comments: 124 (4 by maintainers)

Commits related to this issue

Most upvoted comments

(Solution at bottom!)

So it seems that the problem is in the Python standard library, and I suppose with its interaction with the macOS update:

In [2]: import webbrowser
In [3]: browser=webbrowser.get(None)
In [4]: browser.open("http://python.org")
   0:33: execution error: "http://python.org" doesn’t understand the “open location” message. (-1708)
Out[4]: False

(same behaviour with Python 2 or 3)

However, browser=webbrowser.get("Safari") works!

So, the solution is to explicitly set the browser in ~/.jupyter/jupyter_notebook_config.py (updated from stupidly incorrect file location):

c.NotebookApp.browser = u'Safari'

Ignore the error. Go to http://localhost:8888/tree directly, in your browser.

@jcrotinger: c.NotebookApp.browser = u'chrome' should do the trick.

Upon @rmcantin 's suggestion, editing my ~/.bash_profile file to contain the lines:

BROWSER=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome export BROWSER

worked for me (c.NotebookApp.browser = u’chrome’, did not for whatever reason)

@defjaf: Thanks Andrew for the Safari browser help!

Here the command to create ~/.jupyter_notebook_config.py if it does not exist:

jupyter notebook --generate-config

By the way, I have just found out that if you set the BROWSER variable to open as:

$ export BROWSER=open

it automatically detects your default browser when you run jupyter notebook.

c.NotebookApp.browser = u’chrome’ worked for me!

An alternative workaround is to set the BROWSER environment variable.

For example: export BROWSER=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

For me, this seems to have started with the upgrade to 10.12.5, which dropped on 15 May. But this thread appeared earlier: can anyone who saw this earlier confirm whether they were on the macOS beta?

(Also, this is clearly a bug, even if it’s generated OS-side: “Ignore the error” is only the best solution if it’s not fixable…)

jupyter notebook --browser=Chrome worked for me

Same here with Mac OS and Google Chrome Canary. Error:

0:97: execution error: “http://localhost:8888/tree?token=***” doesn’t understand the “open location” message. (-1708)

This is an Apple event error: “The script doesn’t understand the <message> message. The event was not handled.” AppleScript documentation: https://developer.apple.com/library/content/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_error_codes.html I guess this was caused by recent changes in the latest MacOS revision. The ‘open location’ call run by Jupyter would need to be adapted; meanwhile setting c.NotebookApp.open_browser = False in your jupyter_notebook_config.py and manually copying the NB link helps if one finds the error message annoying.

Here is the solution:

  1. Go to the directory ~/.jupyter: cd ~/.jupyter and create jupyter configuration file: jupyter notebook --generate-config

  2. Now use any editor to open jupyter_notebook_config.py file: nano jupyter_notebook_config.py

  3. Search for the line c.NotebookApp.browser and remove # and then add your browser chrome/safari: c.NotebookApp.browser = u'chrome' NOTE: For some users, c.NotebookApp.browser = u'chrome' doesn’t work. In that case use the following: c.NotebookApp.browser = u'open -a/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome %s'

Done! Now launch the notebook using ipython notebook.

If c.NotebookApp.browser = u'chrome' doesn’t work on your Mac (like it doesn’t on mine), try c.NotebookApp.browser = u'/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome %s' . Worked like a charm.

Same with built-in Terminal and Safari, macOS 10.12.5.

Same issue, latest OS X, looks like a Mac-side problem. Copy/paste link in browser works every time.

For those who couldn’t get it to work with u’Chrome’, try c.NotebookApp.browser = u'open -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome %s'

Guys,

  1. Create “jupyter_notebook_config.py”
  2. Write the following routine inside:

import webbrowser browser=webbrowser.get(“Safari”) browser.open(“http://localhost:8888/tree”)

  1. save it on path ~/.jupyter (command+shift+G)

Good luck!

@defjaf and @bighomeyg thanks for those steps: solved it for me (after I remembered to also uncomment the config line!). Problem cropped up when I upgraded just now to macOS 10.12.5.

@ansteam: try saving it in ~/.jupyter/jupyter_notebook_config.py

@lmarti 's solution works for me on mac 10.12.5 $ export BROWSER=open

To open jupyter notebook in Chrome on a Mac:

  1. run this command: jupyter notebook --generate-config (if ~/.jupyter/jupyter_notebook_config.py does not exist)
  2. open ~/.jupyter/jupyter_notebook_config.py in a text editor
  3. add this line: c.NotebookApp.browser = u'open -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome %s'
  4. try to open jupyter again and it should work

Thanks to @tsatie and @huanhock

P.S. I tried the following and none of them worked:

  • c.NotebookApp.browser = u’chrome’
  • c.NotebookApp.browser = u’Chrome’
  • edit .bash_profile

For what it’s worth, the release notes to macOS 10.12.5 and Safari 10.1.1 don’t appear to have anything listed that would result in this (but my ability to read and understand the security update information is limited).

Also, I just checked in the AppleScript editor, and both Safari and Chrome do understand the “open location http://what.ev.er/” message – but I note that the error message is the “reverse” of this:

0:97: execution error: "http://localhost:8888/tree?token=<removed>" doesn’t understand the “open location” message. (-1708)

I suppose it’s worth a look in the jupyter code to see how this actually gets done…

Same for me just after upgrade to 10.12.5. However, the link works.

Apparently, the underlying osascript bug is fixed in the latest macOS 10.12.6 beta, so that part of the problem will be fixed with the next macOS update (the problem with explicitly setting Chrome is separate, but won’t be an issue if Chrome is set as the default browser).

For those who don’t want to change jupyter_notebook_config.py or BROWSER environment variable, specify --browser flag when launching jupyter, e.g.

jupyter lab --browser=Chrome

Let’s also remember that there is still possibly a bug here: the expectation is that jupyter should use the default browser when c.NotebookApp.browser is unset (as used to be the behaviour). Not clear whether this is a python bug, a macOS bug, or a security feature… but it doesn’t appear to be something specific to jupyter since webbrowser.get().open("http://python.org") fails in python with exactly the error that we all saw.

Be aware that export BROWSER=open will potentially let Python applications which think they’re opening an URL in a “web browser” actually open and potentially run any application or program on your computer, so this isn’t really a safe way to address this problem.

@Imarti $ export BROWSER=open It works for me and so simple way.

Restarted my laptop to update the system and got this error. Going directly to http://localhost:8888/tree, as kjprice suggests, helps in my case.

Can confirm upgrading to 10.12.6 fixes the issue.

Update macOS. The bug is fixed 😃.

For anyone who is unable to locate the jupyter_notebook_config.py file, the solution posted by @defjaf will still work. However you must first create a file with this name within the following directory:

/Users/[your_username]/.jupyter

And once the file is created, you must write the following line to the file:

c.NotebookApp.browser = u'Safari'

Please do not use @rmcantin’s solution 😢 . Upgrade macOS.

If you’re still dealing with this issue, the 10.12.15 system python doesn’t like any solution other than (for chrome, insert path to your browser bundle for something else):

c.NotebookApp.browser = u'open -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome %s'

If you install either python2 or python3 via brew then setting c.NotebookApp.browser to ‘chrome’ will work with or without the unicode decorator so:

c.NotebookApp.browser = 'chrome'

or

c.NotebookApp.browser = u'chrome'

currently experiencing this bug after updating Mac OSX to 10.12.5

c.NotebookApp.browser = u'Safari' worked but c9.io gave me an error about Sockets not working properly in Safari 10.1 and suggested that I use Chrome.

these combinations did not work: u'chrome', u'Chrome', u'Google Chrome' and u'Google\ Chrome'

This finally worked: c.NotebookApp.browser = u'open -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome %s'

thanks @tlwillke and @haccks for solution.

Same problem has folks have noted here - MacOS 10.12.5 upgrade killed it - but adding this to jupyter config did solve the problem:

# Configuration file for jupyter-notebook.
c.NotebookApp.browser = u'chrome'

open terminal in Mac type jupyter notebook --generate-config the output is similar to Writing default config to: /Users/User_name/.jupyter/jupyter_notebook_config.py then type open /Users/User_name/.jupyter/jupyter_notebook_config.py to open the python file find #c.NotebookApp.browser = u' ' and change it to c.NotebookApp.browser = u'Chrome '

@lmarti’s solution below works for me, make sure to add it to your .bash_profile so you won’t have to run it every time you want to open a notebook.

export BROWSER=open

Worked for me, thanks ! And I changed the browser to firefox.

c.NotebookApp.browser = u’firefox’

Thanks, it works for me.

I think the only solution that is browser agnostic is export BROWSER=open

As a side note, the 10.12.5 screwed up a lot of my opens. When I tried to open markdown files using open markdown_file.md it tried to open it using RStudio (it should have used sublime). So I’m inclined to think this is a MacOS bug, not a python one.

@ andrewjmacrae 你的方法有效,谢谢!

@defjaf and @davidjaimes the combination of the two solutions worked for me. Thanks!