gpt4 book ai didi

python - 如何在 Windows 上修复 python 的 getaddrinfo 失败

转载 作者:可可西里 更新时间:2023-11-01 10:27:55 25 4
gpt4 key购买 nike

如果在命令提示符终端中启动 python 并尝试打开一些 url,我会得到以下结果,尽管该名称可通过 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
>>>

我禁用了防火墙,以管理员身份启动命令提示符,但我能想到的差不多就是这些了。 nslookup 工作正常,所以我看不出有什么问题。有什么建议吗?

最佳答案

显然在 Internet Explorer 连接设置中,定义了一个无法访问的代理,并且出于某种原因 urllib 考虑了此设置并因此导致了错误。

关于python - 如何在 Windows 上修复 python 的 getaddrinfo 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8925903/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com