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



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
.



Relevant Pages

  • Re: What is the more popular UNIX flavor?
    ... about my experience with Solaris and Cygwin. ... installing packages. ... needing eg tftp you only need to activate on a Unix system. ... probably need installing first on the equivalent Windows system. ...
    (comp.unix.questions)
  • Re: basic thread question
    ... On Windows we have three different versions of Python 2.6: ... Python 2.6 for Cygwin has os.fork, but it is non-COW and sluggish. ... You get Python 2.6.2 for SUA prebuilt by Microsoft from http://www.interopsystems.com. ...
    (comp.lang.python)
  • Re: Using PHP to parse specific XML tag content?
    ... XML --> HTML transformation in testing environment. ... run just fine under Windows using Cygwin, and, unless I'm ... And they aren't going to run cygwin on these systems, ... It's a programming language designed ...
    (comp.lang.php)
  • Re: Good debugger?
    ... >>Any Tcl core that was built for windows doesn't have that problem. ... >Because Cygwin, by definintion, is not native. ... that's still in script form from prodebug. ... >>But if it can't coexist with native Tcl components, ...
    (comp.lang.tcl)
  • Re: Cygwin or Windows: file permission functions are broken
    ... I don't find the explanation very clear (does "the Windows ... files (Cygwin touch, CMD.EXE copy, anything). ... the Windows permissions mask is way larger of a set than ... When under the "use filetest 'access'" the above-mentioned ...
    (comp.lang.perl.misc)