Sublime Forum

Unable to open web browser from Sublime Text 2

#1

Hello,

I’m using Linux (same problem on Linux Mint & Kubuntu).

First, I installed the “Can I Use” plugin, which can open a webbrowser to the site caniuse.com from a keyword in a CSS file. But it doesn’t open anything.

I thought the plugin was broken, but on a HTML file, right click + “Open in Browser” doesn’t work either.

So I start to search, and search, and search…

Finaly, I found something.

When I type this :

import webbrowser webbrowser.get()

In the Sublime Text console, I got : webbrowser.Error: could not locate runnable browser
In the Python console (Linux Terminal), I got : <webbrowser.BackgroundBrowser object at 0x25f5910>

Obviously, if I type this :

import webbrowser
webbrowser.open_new_tab('http://google.com')

In the Sublime Text console, it returns false and nothing happens.
In the Python console (Linux Terminal), it returns true and my web browser open the page.

So, why the webbrowser doesn’t work inside Sublime Text 2 ?

Thank you :smile:

0 Likes

"Open in Browser" does not work
#2

** :exclamation: Answered it - see below**

I have the same issue on my Mac and ran BlackYeLL first test (no idea about Python - so I didn’t run the second one)

With a different outcome:

import webbrowser webbrowser.get() <webbrowser.MacOSX object at 0x10c667190>

Any idea why it’s not working?

Thanks!

:bulb: Sublime Text 2 was set as my default app for html files. The ‘Open in browser’ command was triggering this default app - not a browser. Changed it back to Firefox and it is working …

0 Likes

#3

Interesting variation on the problem for me…

I couldn’t open files with ‘Open in Browser’.
the console window (crtl + `) showed :

IOError: [Errno 2] No such file or directory: u’/Volumes/HD/WEB SITE FILES/testProject.sublime-project’
reloading /Users/XX/Library/Application Support/Sublime Text 2/Packages/User/Fetch.sublime-settings

I’d deleted a project file that included the directory of the file I was trying to browse.
Retrieving the project file from Trash made everything work again.

:smile:

0 Likes