seaborn.load_dataset导致 URLError: <urlopen 错误 [WinError 10060]


df = sns.load_dataset("tips") 

我正在尝试使用seaborn加载数据集,这导致以下URLError:

TimeoutError                              Traceback (most recent call last)
File ~AppDataLocalProgramsPythonPython311Liburllibrequest.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 ~AppDataLocalProgramsPythonPython311Libhttpclient.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 ~AppDataLocalProgramsPythonPython311Liburllibrequest.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>

我试着改变互联网连接,也试着取消检查代理服务器在局域网设置

  • 错误10060表示您无法连接到远程位置。这种错误可能有以下几个原因:
    • 证书问题。请参阅Stackoverflow上的这篇文章以获取更多详细信息。
    • 这可能是由于网络问题或您的设置问题,如代理设置。要解决这个问题,也可以查看这篇文章。
    • 一些非标准的操作系统,如ChromeOS Flex,可能无法工作,如这里所示。
    • 确保你没有在VPN后面。
  • 尝试用其他方法下载数据
    • 直接与pandas
    • requests,然后加载到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))

相关内容

最新更新