I am trying to run the following code -
import seaborn as sns
df = sns.load_dataset('iris')
but am getting the following error -
---------------------------------------------------------------------------
TimeoutError Traceback (most recent call last)
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\urllib\request.py:1354, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1353 try:
-> 1354 h.request(req.get_method(), req.selector, req.data, headers,
1355 encode_chunked=req.has_header('Transfer-encoding'))
1356 except OSError as err: # timeout error
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\http\client.py:1252, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
1251 """Send a complete request to the server."""
-> 1252 self._send_request(method, url, body, headers, encode_chunked)
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\http\client.py:1298, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked)
1297 body = _encode(body, 'body')
-> 1298 self.endheaders(body, encode_chunked=encode_chunked)
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\http\client.py:1247, in HTTPConnection.endheaders(self, message_body, encode_chunked)
1246 raise CannotSendHeader()
-> 1247 self._send_output(message_body, encode_chunked=encode_chunked)
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\http\client.py:1007, in HTTPConnection._send_output(self, message_body, encode_chunked)
1006 del self._buffer[:]
-> 1007 self.send(msg)
1009 if message_body is not None:
1010
1011 # create a consistent interface to message_body
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\http\client.py:947, in HTTPConnection.send(self, data)
946 if self.auto_open:
--> 947 self.connect()
948 else:
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\http\client.py:1414, in HTTPSConnection.connect(self)
1412 "Connect to a host on a given (SSL) port."
-> 1414 super().connect()
1416 if self._tunnel_host:
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\http\client.py:918, in HTTPConnection.connect(self)
917 """Connect to the host and port specified in __init__."""
--> 918 self.sock = self._create_connection(
919 (self.host,self.port), self.timeout, self.source_address)
920 self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\socket.py:808, in create_connection(address, timeout, source_address)
807 try:
--> 808 raise err
809 finally:
810 # Break explicitly a reference cycle
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\socket.py:796, in create_connection(address, timeout, source_address)
795 sock.bind(source_address)
--> 796 sock.connect(sa)
797 # 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
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
Cell In[14], line 1
----> 1 df = sns.load_dataset('iris')
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\site-packages\seaborn\utils.py:588, in load_dataset(name, cache, data_home, **kws)
586 if name not in get_dataset_names():
587 raise ValueError(f"'{name}' is not one of the example datasets.")
--> 588 urlretrieve(url, cache_path)
589 full_path = cache_path
590 else:
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\urllib\request.py:247, in urlretrieve(url, filename, reporthook, data)
230 """
231 Retrieve a URL into a temporary location on disk.
232
(...)
243 data file as well as the resulting HTTPMessage object.
244 """
245 url_type, path = _splittype(url)
--> 247 with contextlib.closing(urlopen(url, data)) as fp:
248 headers = fp.info()
250 # Just return the local path and the "headers" for file://
251 # URLs. No sense in performing a copy unless requested.
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\urllib\request.py:222, in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220 else:
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\urllib\request.py:525, in OpenerDirector.open(self, fullurl, data, timeout)
522 req = meth(req)
524 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 525 response = self._open(req, data)
527 # post-process response
528 meth_name = protocol+"_response"
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\urllib\request.py:542, in OpenerDirector._open(self, req, data)
539 return result
541 protocol = req.type
--> 542 result = self._call_chain(self.handle_open, protocol, protocol +
543 '_open', req)
544 if result:
545 return result
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\urllib\request.py:502, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
500 for handler in handlers:
501 func = getattr(handler, meth_name)
--> 502 result = func(*args)
503 if result is not None:
504 return result
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\urllib\request.py:1397, in HTTPSHandler.https_open(self, req)
1396 def https_open(self, req):
-> 1397 return self.do_open(http.client.HTTPSConnection, req,
1398 context=self._context, check_hostname=self._check_hostname)
File c:\Users\Argish\AppData\Local\Programs\Python\Python38\lib\urllib\request.py:1357, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1354 h.request(req.get_method(), req.selector, req.data, headers,
1355 encode_chunked=req.has_header('Transfer-encoding'))
1356 except OSError as err: # timeout error
-> 1357 raise URLError(err)
1358 r = h.getresponse()
1359 except:
URLError:
Note - The last line is copy pasted as it is, there is nothing written after "URLError:"
I am using Python 3.8.10
and Jupyter Notebook in VSCode.
I tried uninstalling and reinstalling seaborn, but it didn't help.
I tried the solution presented on this website but it didn't help either.
I have stable internet connection and I checked my firewall settings, nothing seems to be blocking python from getting internet connection. I can't figure out what exactly is the problem here.
Kindly help me out. Thank You.
Edit - it works fine when I switch to Python 3.10.6
.