How to fix getaddrinfo-failure for python on windows

我怕爱的太早我们不能终老 提交于 2019-12-29 09:02:07

问题


if a start python in a command prompt terminal and try to open some url, I get the following result, despite the name being resolveable through DNS:

C:\Windows\system32>nslookup www.google.de
Nicht-autorisierende Antwort:
Name:    www-cctld.l.google.com
Address:  173.194.69.94
Aliases:  www.google.de
C:\Windows\system32>C:\Python27\python.exe
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>> urllib.urlopen("http://www.google.de")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\urllib.py", line 84, in urlopen
    return opener.open(url)
  File "C:\Python27\lib\urllib.py", line 205, in open
    return getattr(self, name)(url)
  File "C:\Python27\lib\urllib.py", line 342, in open_http
    h.endheaders(data)
  File "C:\Python27\lib\httplib.py", line 951, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 811, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 773, in send
    self.connect()
  File "C:\Python27\lib\httplib.py", line 754, in connect
    self.timeout, self.source_address)
  File "C:\Python27\lib\socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
IOError: [Errno socket error] [Errno 11001] getaddrinfo failed
>>>

I disabled the firewall, started the command prompt as Administrator, but that’s pretty much all I can think of. nslookup works just fine, so I don't see what’s wrong. Any suggestions?


回答1:


Apparently within Internet Explorer connection settings, an unreachable proxy was defined and for whatever reason urllib considers this setting and thus caused the error.



来源:https://stackoverflow.com/questions/8925903/how-to-fix-getaddrinfo-failure-for-python-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!