webbrowser.open works in IDLE and cmd shell but not from cygwin prompt

Discussion in 'Python' started by Gregory Bloom, Apr 27, 2007.

  1. I'm running Python 2.5 under Windows. If I fire up IDLE and enter:

    >>> import webbrowser
    >>> url = 'http://www.python.org'
    >>> webbrowser.open_new(url)


    it works like a champ, opening the page in Firefox. Same thing goes
    from a Windows cmd shell: it works as advertised.

    But if I open a cygwin bash shell and try the same thing from a python
    prompt, I get:

    >>> import webbrowser
    >>> url = 'http://www.python.org'
    >>> webbrowser.open_new(url)

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "C:\Python25\lib\webbrowser.py", line 60, in open_new
    return open(url, 1)
    File "C:\Python25\lib\webbrowser.py", line 55, in open
    if browser.open(url, new, autoraise):
    File "C:\Python25\lib\webbrowser.py", line 185, in open
    p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid)
    File "C:\Python25\lib\subprocess.py", line 551, in __init__
    raise ValueError("close_fds is not supported on Windows "
    ValueError: close_fds is not supported on Windows platforms

    What's up with that? And, more to the point, how can I use webbrowser
    from scripts launched under cygwin?
    Gregory Bloom, Apr 27, 2007
    #1
    1. Advertising

  2. Gregory Bloom

    Paddy Guest

    On Apr 27, 5:09 am, Gregory Bloom <> wrote:
    > I'm running Python 2.5 under Windows. If I fire up IDLE and enter:
    >
    > >>> import webbrowser
    > >>> url = 'http://www.python.org'
    > >>> webbrowser.open_new(url)

    >
    > it works like a champ, opening the page in Firefox. Same thing goes
    > from a Windows cmd shell: it works as advertised.
    >
    > But if I open a cygwin bash shell and try the same thing from a python
    > prompt, I get:
    >
    > >>> import webbrowser
    > >>> url = 'http://www.python.org'
    > >>> webbrowser.open_new(url)

    >
    > Traceback (most recent call last):
    > File "<stdin>", line 1, in <module>
    > File "C:\Python25\lib\webbrowser.py", line 60, in open_new
    > return open(url, 1)
    > File "C:\Python25\lib\webbrowser.py", line 55, in open
    > if browser.open(url, new, autoraise):
    > File "C:\Python25\lib\webbrowser.py", line 185, in open
    > p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid)
    > File "C:\Python25\lib\subprocess.py", line 551, in __init__
    > raise ValueError("close_fds is not supported on Windows "
    > ValueError: close_fds is not supported on Windows platforms
    >
    > What's up with that? And, more to the point, how can I use webbrowser
    > from scripts launched under cygwin?


    I have X and kde for cygwin installed.
    If i use startxwin to start an xterm, without starting kde, and do
    the
    above in cygwins python version 2.4.3 i have to wait around 3 minutes
    then up pops konqueror at the requested page.

    - Paddy.
    Paddy, Apr 27, 2007
    #2
    1. Advertising

  3. Re: webbrowser.open works in IDLE and cmd shell but not from cygwinprompt

    Gregory Bloom wrote:
    > I'm running Python 2.5 under Windows. If I fire up IDLE and enter:
    >
    >>>> import webbrowser
    >>>> url = 'http://www.python.org'
    >>>> webbrowser.open_new(url)

    >
    > it works like a champ, opening the page in Firefox. Same thing goes
    > from a Windows cmd shell: it works as advertised.
    >
    > But if I open a cygwin bash shell and try the same thing from a python
    > prompt, I get:
    >
    >>>> import webbrowser
    >>>> url = 'http://www.python.org'
    >>>> webbrowser.open_new(url)

    > Traceback (most recent call last):
    > File "<stdin>", line 1, in <module>
    > File "C:\Python25\lib\webbrowser.py", line 60, in open_new
    > return open(url, 1)
    > File "C:\Python25\lib\webbrowser.py", line 55, in open
    > if browser.open(url, new, autoraise):
    > File "C:\Python25\lib\webbrowser.py", line 185, in open
    > p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid)
    > File "C:\Python25\lib\subprocess.py", line 551, in __init__
    > raise ValueError("close_fds is not supported on Windows "
    > ValueError: close_fds is not supported on Windows platforms
    >
    > What's up with that?


    It's not a Cygwin issue, really. This occurs when one of ["firefox",
    "firebird", "seamonkey", "mozilla", "netscape", "opera"] is in your
    path. Your Cygwin environment must be set so one of these is in your
    path when it isn't normally.

    You should also submit a bug.

    > And, more to the point, how can I use webbrowser from scripts launched under
    > cygwin?


    If you're using native Windows Python as you seem to be, try
    webbrowser.get("windows-default").open_new(url)

    If you want to use Cygwin Python instead, I submitted a patch more than
    1.5 years ago to allow it, but it hasn't been reviewed:

    http://python.org/sf/1244861
    --
    Michael Hoffman
    Michael Hoffman, Apr 27, 2007
    #3
  4. On Apr 27, 3:12 am, Michael Hoffman <> wrote:
    > > And, more to the point, how can I use webbrowser from scripts launched under

    >
    > > cygwin?

    >
    > If you're using native Windows Python as you seem to be, try
    > webbrowser.get("windows-default").open_new(url)
    >
    > If you want to use Cygwin Python instead, I submitted a patch more than
    > 1.5 years ago to allow it, but it hasn't been reviewed:
    >
    > http://python.org/sf/1244861
    > --
    > Michael Hoffman



    Awesome! That works perfectly. Thanks.
    Gregory Bloom, Apr 27, 2007
    #4
  5. Gregory Bloom

    Steve Holden Guest

    Re: webbrowser.open works in IDLE and cmd shell but not from cygwinprompt

    Gregory Bloom wrote:
    > On Apr 27, 3:12 am, Michael Hoffman <> wrote:
    >>> And, more to the point, how can I use webbrowser from scripts launched under
    >> > cygwin?

    >>
    >> If you're using native Windows Python as you seem to be, try
    >> webbrowser.get("windows-default").open_new(url)
    >>
    >> If you want to use Cygwin Python instead, I submitted a patch more than
    >> 1.5 years ago to allow it, but it hasn't been reviewed:
    >>
    >> http://python.org/sf/1244861
    >> --
    >> Michael Hoffman

    >
    >
    > Awesome! That works perfectly. Thanks.
    >
    >

    Interestingly when I tried this under Cygwin I got the links browser
    displaying the material from the given URL.

    That's different enough that I might keep it like that.:)

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://del.icio.us/steve.holden
    ------------------ Asciimercial ---------------------
    Get Python in your .sig and on the web. Blog and lens
    holdenweb.blogspot.com squidoo.com/pythonology
    tag items: del.icio.us/steve.holden/python
    All these services currently offer free registration!
    -------------- Thank You for Reading ----------------
    Steve Holden, Apr 28, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gaurav kashyap
    Replies:
    2
    Views:
    591
    gaurav kashyap
    Oct 30, 2008
  2. gaurav kashyap
    Replies:
    3
    Views:
    653
    gaurav kashyap
    Oct 31, 2008
  3. gaurav kashyap

    open a shell prompt froma python program

    gaurav kashyap, Oct 30, 2008, in forum: Python
    Replies:
    8
    Views:
    251
    Lawrence D'Oliveiro
    Nov 1, 2008
  4. geefypants
    Replies:
    0
    Views:
    140
    geefypants
    Oct 28, 2004
  5. Eric Lewton
    Replies:
    3
    Views:
    104
    Eric Lewton
    Dec 1, 2003
Loading...

Share This Page