Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

seaborn.load_dataset results in URLError: <urlopen error [WinError 10060]

df = sns.load_dataset("tips") 

I am trying to load dataset using seaborn, which results in the follow URLError:

TimeoutError                              Traceback (most recent call last)
File ~\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py:1348, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
   1347 try:
-> 1348     h.request(req.get_method(), req.selector, req.data, headers,
   1349               encode_chunked=req.has_header('Transfer-encoding'))
   1350 except OSError as err: # timeout error

File ~\AppData\Local\Programs\Python\Python311\Lib\http\client.py:1282, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
   1281 """Send a complete request to the server."""
-> 1282 self._send_request(method, url, body, headers, encode_chunked)



File ~\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py:241, in urlretrieve(url, filename, reporthook, data)
    224 """
    225 Retrieve a URL into a temporary location on disk.
    226 
   (...)
    237 data file as well as the resulting HTTPMessage object.
    238 """
    239 url_type, path = _splittype(url)
--> 241 with contextlib.closing(urlopen(url, data)) as fp:
    242     headers = fp.info()
    244     # Just return the local path and the "headers" for file://
    245     # URLs. No sense in performing a copy unless requested.



URLError: <urlopen error [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>

I tried changing the internet connection and also tried unchecking the proxy server in LAN settings

like image 555
Rehan Ahmad Avatar asked Nov 03 '25 07:11

Rehan Ahmad


2 Answers

Check the data cached path using

sns.get_data_home()

which returns something like - 'C:\\Users\\xyz\\AppData\\Local\\seaborn\\seaborn\\Cache'

Then download a copy of the dataset from "https://github.com/mwaskom/seaborn-data" to the cached path. It should resolve the problem.

This method resolved ConnectionResetError

like image 97
VJ aka Vijay Avatar answered Nov 04 '25 20:11

VJ aka Vijay


  • The error 10060 means you cannot connect to the remote place. There might be several reasons for such an error:
    • See Unable to get local issuer certificate when using requests for problems with certificates.
    • It might be because of the network's problems or your setting issues, such as proxy settings. To solve this issue, check How to resolve URLError: <urlopen error [Errno 10060].
    • Some non-standard OSs, like ChromeOS Flex, may not work, as indicated here.
    • Make sure you're not behind a VPN.
    • That said, there isn't much we can do to resolve this type of issue.
  • Try downloading the data with an alternate method
    • directly with pandas
    • with requests and then load into pandas
import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv')
import requests
import io

t = requests.get('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/tips.csv').text

df = pd.read_csv(io.StringIO(t))
like image 30
dzhu_man_dzhi Avatar answered Nov 04 '25 20:11

dzhu_man_dzhi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!