我正在尝试在jupyter Notebooks中运行以下代码
from sklearn.datasets import fetch_mldata
mnist = fetch_mldata('MNIST original')
并出现以下错误
TimeoutError Traceback (most recent call last)
~\Anaconda3\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args)
1316 h.request(req.get_method(), req.selector, req.data, headers,
-> 1317 encode_chunked=req.has_header('Transfer-encoding'))
1318 except OSError as err: # timeout error
~\Anaconda3\lib\http\client.py in request(self, method, url, body, headers, encode_chunked)
1243 """Send a complete request to the server."""
-> 1244 self._send_request(method, url, body, headers, encode_chunked)
1245
~\Anaconda3\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked)
1289 body = _encode(body, 'body')
-> 1290 self.endheaders(body, encode_chunked=encode_chunked)
1291
~\Anaconda3\lib\http\client.py in endheaders(self, message_body, encode_chunked)
1238 raise CannotSendHeader()
-> 1239 self._send_output(message_body, encode_chunked=encode_chunked)
1240
~\Anaconda3\lib\http\client.py in _send_output(self, message_body, encode_chunked)
1025 del self._buffer[:]
-> 1026 self.send(msg)
1027
~\Anaconda3\lib\http\client.py in send(self, data)
965 if self.auto_open:
--> 966 self.connect()
967 else:
~\Anaconda3\lib\http\client.py in connect(self)
937 self.sock = self._create_connection(
--> 938 (self.host,self.port), self.timeout, self.source_address)
939 self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
~\Anaconda3\lib\socket.py in create_connection(address, timeout, source_address)
726 if err is not None:
--> 727 raise err
728 else:
~\Anaconda3\lib\socket.py in create_connection(address, timeout, source_address)
715 sock.bind(source_address)
--> 716 sock.connect(sa)
717 # Break explicitly a reference cycle
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
我正在Windows 10计算机上使用Anaconda {version:'4.7.12'},python {version:'3.7.4'}
这与HTTP代理有关吗?我不确定如何使用jupyter笔记本进行配置。请帮忙。
答案 0 :(得分:2)
看起来您并不孤单。我也遇到超时错误。我没有使用代理服务器或jupyter,因此可能只是源已关闭。
>>> from sklearn.datasets import fetch_mldata
>>> mnist = fetch_mldata('MNIST original')
...
TimeoutError: [Errno 60] Operation timed out
根据https://github.com/scikit-learn/scikit-learn/issues/8588的讨论,看来这是一个范围更广的问题。
以下来源对我有用。
>>> from sklearn.datasets import fetch_openml
>>> mnist = fetch_openml('mnist_784')