By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,386 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,386 IT Pros & Developers. It's quick & easy.

urllib on windows machines

P: n/a
I've got a strange problem on windows (not very familiar with that OS).

I can ping a host, but cannot get it via urllib (see here under).
I can even telnet the host on port 80.

Thus network seems good, but not for python ;-(.

Does any windows specialist can guide me (a poor linux user) to get
Network functionalitiies with python on windows ?

I'm runnning on Windows XP (sorry to not give more, I don't know the
equivalent of uname).
I'm using standard (msi) python-2.4.2

Thanks.

test.py contains the following lines:
"
import urllib
g=urllib.urlopen('http://www.google.com')
"
C:\Temp>python test.py
Traceback (most recent call last):
File "test.py", line 2, in ?
g=urllib.urlopen('http://www.google.com')
File "c:\william\tools\python24\lib\urllib.py", line 77, in urlopen
return opener.open(url)
File "c:\william\tools\python24\lib\urllib.py", line 185, in open
return getattr(self, name)(url)
File "c:\william\tools\python24\lib\urllib.py", line 308, in
open_http
h.endheaders()
File "c:\william\tools\python24\lib\httplib.py", line 795, in
endheaders
self._send_output()
File "c:\william\tools\python24\lib\httplib.py", line 676, in
_send_output
self.send(msg)
File "c:\william\tools\python24\lib\httplib.py", line 643, in send
self.connect()
File "c:\william\tools\python24\lib\httplib.py", line 627, in connect
raise socket.error, msg
IOError: [Errno socket error] (10053, 'Software caused connection
abort')

C:\Temp>ping www.google.com

Pinging www.l.google.com [66.249.93.104] with 32 bytes of data:

Reply from 66.249.93.104: bytes=32 time=22ms TTL=246
Reply from 66.249.93.104: bytes=32 time=23ms TTL=246
Reply from 66.249.93.104: bytes=32 time=22ms TTL=246
Reply from 66.249.93.104: bytes=32 time=22ms TTL=246

Ping statistics for 66.249.93.104:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 22ms, Maximum = 23ms, Average = 22ms

Dec 3 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
wi*****@opensource4you.com wrote:
I've got a strange problem on windows (not very familiar with that OS).
I can ping a host, but cannot get it via urllib (see here under).
.... Thus network seems good, but not for python ;-(.

Does any windows specialist can guide me (a poor linux user) to get
Network functionalitiies with python on windows ?

I'm runnning on Windows XP (sorry to not give more, I don't know the
equivalent of uname).
This part I can help you with:
import platform
platform.platform() 'Windows-2000-5.0.2195-SP4' # in my case platform.architecture() ('32bit', 'WindowsPE') platform.python_version() '2.4.2' platform.python_compiler() 'MSC v.1310 32 bit (Intel)' platform.python_build() (67, 'Sep 28 2005 12:41:11')
test.py contains the following lines:
"
import urllib
g=urllib.urlopen('http://www.google.com')
"
...


I'm on a Win2K 2.4.2 system, and Idle let's me do: import urllib
g = urllib.urlopen('http://www.google.com')
g.read(12)

'<html><head>'

So off-hand, I'd suspect some firewall thingie is getting in the way.
Can you "bless" \Python24\python.exe and \Python24\pythonw.exe as
applications allowed to do net traffic?

--Scott David Daniels
sc***********@acm.org
Dec 3 '05 #2

P: n/a
Thanks Scott

This part I can help you with:
>>> import platform
>>> platform.platform() 'Windows-2000-5.0.2195-SP4' # in my case >>> platform.architecture() ('32bit', 'WindowsPE') >>> platform.python_version() '2.4.2' >>> platform.python_compiler() 'MSC v.1310 32 bit (Intel)' >>> platform.python_build() (67, 'Sep 28 2005 12:41:11')
import platform
platform.platform() 'Windows-XP-5.1.2600' platform.architecture() ('32bit', 'WindowsPE') platform.python_version() '2.4.2' platform.python_compiler() 'MSC v.1310 32 bit (Intel)' platform.python_build()

(67, 'Sep 28 2005 12:41:11')

So off-hand, I'd suspect some firewall thingie is getting in the way.
Can you "bless" \Python24\python.exe and \Python24\pythonw.exe as
applications allowed to do net traffic?


Bingo!!!!!
That's the problem: "Blocked outgoing TCP - Source Local: (1898)
Destination: 67.18.1.164: http(80)"

But why the "telnet www.google.com 80" is wroking ?
Why Firefox is running ?

Thanks.

William

Dec 3 '05 #3

P: n/a
wi*****@opensource4you.com wrote:
...

[I said]
So off-hand, I'd suspect some firewall thingie is getting in the way.
Can you "bless" \Python24\python.exe and \Python24\pythonw.exe as
applications allowed to do net traffic?


Bingo!!!!!
That's the problem: "Blocked outgoing TCP - Source Local: (1898)
Destination: 67.18.1.164: http(80)"

But why the "telnet www.google.com 80" is wroking ?
Why Firefox is running ?


Because (and I'm guessing here), telnet, ftp, firefox, ... are all
web-specific, and they are not regarded as possible monsters if they
try to connect to the web. I'd like the chance to deny all programs
that I don't expect to connect out the chance to do so, but there has
got to be a way to turn it off. Maybe there are some adjustments to
the program that emitted the "Blocked outgoing TCP - ..." message.

--
-Scott David Daniels
sc***********@acm.org
Dec 3 '05 #4

P: n/a
wi*****@opensource4you.com wrote:
I've got a strange problem on windows (not very familiar with that OS).

I can ping a host, but cannot get it via urllib (see here under).
I can even telnet the host on port 80.

Thus network seems good, but not for python ;-(.

Does any windows specialist can guide me (a poor linux user) to get
Network functionalitiies with python on windows ?

I'm runnning on Windows XP (sorry to not give more, I don't know the
equivalent of uname).
I'm using standard (msi) python-2.4.2

Thanks.

test.py contains the following lines:
"
import urllib
g=urllib.urlopen('http://www.google.com')
"
C:\Temp>python test.py
Traceback (most recent call last):
File "test.py", line 2, in ?
g=urllib.urlopen('http://www.google.com')
File "c:\william\tools\python24\lib\urllib.py", line 77, in urlopen
return opener.open(url)
File "c:\william\tools\python24\lib\urllib.py", line 185, in open
return getattr(self, name)(url)
File "c:\william\tools\python24\lib\urllib.py", line 308, in
open_http
h.endheaders()
File "c:\william\tools\python24\lib\httplib.py", line 795, in
endheaders
self._send_output()
File "c:\william\tools\python24\lib\httplib.py", line 676, in
_send_output
self.send(msg)
File "c:\william\tools\python24\lib\httplib.py", line 643, in send
self.connect()
File "c:\william\tools\python24\lib\httplib.py", line 627, in connect
raise socket.error, msg
IOError: [Errno socket error] (10053, 'Software caused connection
abort')

C:\Temp>ping www.google.com

Pinging www.l.google.com [66.249.93.104] with 32 bytes of data:

Reply from 66.249.93.104: bytes=32 time=22ms TTL=246
Reply from 66.249.93.104: bytes=32 time=23ms TTL=246
Reply from 66.249.93.104: bytes=32 time=22ms TTL=246
Reply from 66.249.93.104: bytes=32 time=22ms TTL=246

Ping statistics for 66.249.93.104:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 22ms, Maximum = 23ms, Average = 22ms

Something is clearly wrong. here's *my* XP system connecting to Google:

C:\Steve>python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
import urllib
f = urllib.urlopen('http://www.google.com')
len(f.read()) 2690


I suspect you may have a firewall problem: you could need to tell your
(XP Service Pack 2 personal) firewall it's OK for Python to make
outbound network connections.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Dec 4 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.