0

This explains my issue very well:

http://www.sublimetext.com/forum/viewtopic.php?f=3&t=8513

Running the following command in python interactive terminal works, but not when added as a sublime text 2 plugin:

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

I need to preview an HTML page in a browser.

EDIT: In sublime text I get something like:

webbrowser.Error: could not locate runnable browser

EDIT

I even tried this:

import sublime, sublime_plugin
import webbrowser
from subprocess import call

class OpenBrowserCommand(sublime_plugin.TextCommand):
    def run(self,edit):
        url = self.view.file_name()
        url = '"file://{url}"'.format(url=url)
        firefox = '"/Applications/Firefox.app"'
        print url
        call(["open", "-a", firefox, url])
MattDMo
  • 100,794
  • 21
  • 241
  • 231
Mazyod
  • 22,319
  • 10
  • 92
  • 157
  • try running the code in the Sublime console (`ctrl+\``) and see what happens. It's working fine for me on XP (sorry, I'm not at my Mac at the moment) – MattDMo Nov 25 '13 at 15:53
  • @MattDMo It's cool, I updated my question with details about what I see – Mazyod Nov 25 '13 at 19:50
  • sorry for getting back to you late, but I just ran across your question in my open tabs :) I tried running your original code (the 2-liner) in the ST2 console and it worked fine for me on my Mac, too, so I would assume that there is something wrong with the associations on your computer, as indicated by your error message. Perhaps try removing and reinstalling Firefox.app? – MattDMo Dec 03 '13 at 03:32
  • @MattDMo You can enable email notifications, but it's up to you. I doubt it's firefox related. I tried the 2-liner in the sublime interactive terminal, and it works. The open browser command seems to be the issue. – Mazyod Dec 03 '13 at 07:51

0 Answers0