473,547 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.op en_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.op en_new(url)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\li b\webbrowser.py ", line 60, in open_new
return open(url, 1)
File "C:\Python25\li b\webbrowser.py ", line 55, in open
if browser.open(ur l, new, autoraise):
File "C:\Python25\li b\webbrowser.py ", line 185, in open
p = subprocess.Pope n(cmdline, close_fds=True, preexec_fn=sets id)
File "C:\Python25\li b\subprocess.py ", line 551, in __init__
raise ValueError("clo se_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 3736
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.ope n_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.ope n_new(url)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\li b\webbrowser.py ", line 60, in open_new
return open(url, 1)
File "C:\Python25\li b\webbrowser.py ", line 55, in open
if browser.open(ur l, new, autoraise):
File "C:\Python25\li b\webbrowser.py ", line 185, in open
p = subprocess.Pope n(cmdline, close_fds=True, preexec_fn=sets id)
File "C:\Python25\li b\subprocess.py ", line 551, in __init__
raise ValueError("clo se_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.o pen_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.o pen_new(url)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\li b\webbrowser.py ", line 60, in open_new
return open(url, 1)
File "C:\Python25\li b\webbrowser.py ", line 55, in open
if browser.open(ur l, new, autoraise):
File "C:\Python25\li b\webbrowser.py ", line 185, in open
p = subprocess.Pope n(cmdline, close_fds=True, preexec_fn=sets id)
File "C:\Python25\li b\subprocess.py ", line 551, in __init__
raise ValueError("clo se_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...@mh39 1.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...@mh39 1.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.blogs pot.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
2587
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 window, but no toolbar. If I type idle foobar.py it brings both shell and editor windows, but once again, no toolbar on either window -- which...
1
2359
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 window or edit window). Does anyone know why and if there is a workaround? TIA. (I know I should probably ask Cygwin folks, but just want to check...
3
397
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 advance Regards
15
7367
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 history command in IDLE (in fact with IDLE in general). Often I'll develop new code at the command line, testing each line as I go. Currently I have...
8
3760
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 installation issue. When the person who has the problem logs into another PC the problem follows them. Any ideas as to what might me wrong? This is the...
4
8210
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. Is it possible, and if so, how? tia, Bill
6
5236
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 goes there"? http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python/Who_Goes_There%3F But after clicking "run module" for " a = 1
14
2075
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 information. True It opens firefox as expected, but the url is ...
4
2274
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 dbi modules. However, when I restart the shell and type "import odbc" at the prompt by, I don't get an error. When I try to run the program now, I...
0
7507
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7461
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7794
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3492
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.