python-3.x - WinError 10061 - 无法建立连接

标签 python-3.x

我正在调试一个简单的程序,该程序过去一直有效。我已经挑出了发生错误的指令,但我无法弄清楚是什么触发了它。我已阅读与 WinError 10061 相关的所有问题,但没有看到明确的答案

urllib.request.urlopen('http://www.wikipedia.org/')
Traceback (most recent call last):
File "C:\Python33\lib\urllib\request.py", line 1248, in do_open    h.request(req.get_method(), req.selector, req.data, headers)
File "C:\Python33\lib\http\client.py", line 1061, in request    self._send_request(method, url, body, headers)
File "C:\Python33\lib\http\client.py", line 1099, in _send_request    self.endheaders(body)
File "C:\Python33\lib\http\client.py", line 1057, in endheaders  self._send_output(message_body)
File "C:\Python33\lib\http\client.py", line 902, in _send_output    self.send(msg)
File "C:\Python33\lib\http\client.py", line 840, in send    self.connect()
File "C:\Python33\lib\http\client.py", line 818, in connect    self.timeout, self.source_address)
File "C:\Python33\lib\socket.py", line 435, in create_connection    raise err
File "C:\Python33\lib\socket.py", line 426, in create_connection    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred: 

Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
urllib.request.urlopen('http://www.wikipedia.org/')
File "C:\Python33\lib\urllib\request.py", line 156, in urlopen   return opener.open(url, data, timeout)
File "C:\Python33\lib\urllib\request.py", line 469, in open    response = self._open(req, data)
File "C:\Python33\lib\urllib\request.py", line 487, in _open    '_open', req)
File "C:\Python33\lib\urllib\request.py", line 447, in _call_chain    result = func(*args)
File "C:\Python33\lib\urllib\request.py", line 1268, in http_open    return self.do_open(http.client.HTTPConnection, req)
File "C:\Python33\lib\urllib\request.py", line 1251, in do_open    raise URLError(err)
urllib.error.URLError: <urlopen error [WinError 10061] No connection could be made because the target machine actively refused it>

我在 Windows 8 中运行 Python 3。我尝试关闭防火墙,正如一些人建议的那样,但没有任何变化。我还尝试将 Python 添加到防火墙允许的应用程序列表中。顺便说一下,直到几天前,当我从 PC 中删除了一些应用程序时,程序行才没有任何问题。

最佳答案

原来,Internet 属性、连接选项卡、局域网设置被设置为代理服务器。我将其更改为自动检测设置,然后一切重新开始正常工作。

关于python-3.x - WinError 10061 - 无法建立连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20437701/

相关文章:

python-3.x - 如何向检测到的 OCR 边界框添加填充?

python - Python中黑名单和白名单的字符串处理

python - 如何调试 "guessing number"游戏中的错误结果?

python - 正则表达式在缩写后添加逗号

python - 如何在 sckikit-learn 中将数据帧列的分类值转换为 one-hot 编码列?

python - 在 Python 中从 Chrome 获取所有打开的网站

python-3.x - 使用 Pandas 查找行中的最大值并用该列名称填充新列?

python - Pandas Apply 函数无法始终如一地工作(Python 3)

python-3.x - 以 csv 形式获取特征提取结果

python - 为什么在导入 datetime 类后不能使用此引用?