urllib on windows machines
Steve Holden
steve at holdenweb.com
Sun Dec 4 05:47:59 EST 2005
william at 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/
More information about the Python-list
mailing list