Dejas
Dejas

Reputation: 3621

Can't launch a web browser in OS X via "open_new"? (Works fine on windows)

The following program opens a browser and navigates to www.cnn.com on Windows, but in OS X nothing happens. I'm not sure why.

import webbrowser
webbrowser.open_new("www.cnn.com")

Any thoughts?

Upvotes: 3

Views: 1118

Answers (1)

Bill Lynch
Bill Lynch

Reputation: 81926

You need to do:

import webbrowser
webbrowser.open_new("http://www.cnn.com")

On OS X, this is converted to the following shell command:

echo 'open location "http://www.cnn.com"' | osascript

For whatever reason, open location www.cnn.com does not work in osascript on OS X.

This was tested on OS X Lion.

Upvotes: 7

Related Questions