473,396 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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?

Apr 27 '07 #1
4 3726
On Apr 27, 5:09 am, Gregory Bloom <Gregory.Bl...@gmail.comwrote:
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.

Apr 27 '07 #2
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
Apr 27 '07 #3
On Apr 27, 3:12 am, Michael Hoffman <cam.ac...@mh391.invalidwrote:
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.
Apr 27 '07 #4
Gregory Bloom wrote:
On Apr 27, 3:12 am, Michael Hoffman <cam.ac...@mh391.invalidwrote:
>>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 ----------------

Apr 28 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Porky Pig Jr | last post by:
Just downloaded and installed the latest Cygwin distribution which includes python 2.3.4. IDLE runs fine but for some reason the toolbar menu doesn't show up. Like, by default, it starts shell...
1
by: Porky Pig Jr | last post by:
A question for those using python under Cygwin. I've just installed the latest distribution with python 2.3.4. One problem I have is when I start IDLE, it doesn't show toolbar menu (either shell...
3
by: Rolf Wester | last post by:
Hi, I would like to use IDLE as interactively as I can with Emacs. In Emacs I can send a marked region to the Python interpreter. Is there any way to do the same thing with IDLE? Thank you in...
15
by: Ashot | last post by:
This is sort of both Python and Vim related (which is why I've posted to both newsgroups). Python related: ---------------------- I have been frustrated for quite some time with a lack of a...
8
by: Jonathan Polley | last post by:
I have one account on a WindowsXP machine that refuses to run IDLE (or any other python script that uses Tk). Other people can login to that PC and IDLE runs just fine, so it is not an...
4
by: Bill Davy | last post by:
To make life easier for my users, I'd like to colour my prompt string (as handed to raw_input()) a different colour to that produced by print. I'm using Python 2.4.1 and IDLE 1.1.1 on Windows XP. ...
6
by: John (Z R) L | last post by:
Hi all, I am very new to programming, and I chose to study the Python language before C++. I am currently using the Wikibooks "Non-Programmer's Tutorial for Python", and am up to the section "Who...
14
by: Ron Adam | last post by:
Is anyone else having problems with the webbrowser module? Python 2.5.1c1 (release25-maint, Apr 12 2007, 21:00:25) on linux2 Type "help", "copyright", "credits" or "license" for more...
4
by: boblatest | last post by:
Hello, I wrote aprogram that imports odbc and dbi. Originally I used PyWin, but now I prefer IDLE for working in Windows. Anyway, when I start my program from IDLE, it can't import the odbc and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.