Webbrowser package supported on macOS?

I’m trying to use Python’s webbrowser package to open a Web page at a particular point in my script, running on Rhino 7.9 on macOS 11.4:

import webbrowser

The code runs without an error, but the browser window doesn’t open. Is this operation not supported on macOS, or am I doing something wrong? Thank you!

Hey @jeff.garbers,

What does this output?

import webbrowser as wb
for name in wb._browsers:

– Dale

Hi, Dale! Sorry for the late answer - I didn’t get a notification of your reply. The script you provided generates no output; I modified it to make sure it actually ran. Where from here? Thanks!

To clarify, wb._browsers is an empty dict on macOS.

Hi @jeff.garbers,

webbrowser.py is part of the standard library that comes with IronPython, the interpreter used by Rhino. If it doesn’t work on macOS, I doubt there is anything we can do about it.

What exactly are you trying to do, and why?

– Dale

Okay, it sounds like this is an IronPython on Mac limitation, then… thanks! I would like to have my plugin be able to open a URL under various circumstances for help, authentication, and other support functions.

For a little extra context, the IronPython docs suggest that webbrowser is supported on macOS, as it mentions a “macosx” option that, it seems, should open the default browser.

However, this script, which attempts to create a browser controller object:

import webbrowser as wb
b = wb.get("macosx")

generates the following error:

Message: could not locate runnable browser


line 52, in get, "/Applications/Rhino 7.app/Contents/Frameworks/RhCore.framework/Versions/Current/Resources/ManagedPlugIns/RhinoDLR_Python.rhp/Lib/webbrowser.py"

line 2, in <module>, "/var/folders/7t/36p4w6_d4m1_8p5zkdrkdp9r0000gn/T/TempScript.py"

Dunno if that dump gives you any insight as to whether this could be specific to Rhino or not, but I thought I’d pass it along… thanks again!

Maybe this?

import Rhino
url = 'https://www.rhino3d.com/'
script = '_-Run {0}'.format(url)
Rhino.RhinoApp.RunScript(script, False)

– Dale

That gives me “Unknown command: _-Run” down in the status bar…?

That script does launch the browser when run from Rhino on Windows, though…

Geez, how about this?

import System
url = 'https://www.rhino3d.com/'

– Dale


That did the trick! Opened Safari like a champ. This is some slightly dark magic, it appears… is it okay to use System.Diagnostics for stuff like this? I suppose you gotta do what you gotta do… Thank you!

does not work for me on mac
it works for me on windows. On mac I need:import System
url = ‘https://www.rhino3d.com/
System.Diagnostics.Process.Start(“open”, url)