今天上课的时候老师的样例用到了iris数据样例
import seaborn的时候报错了
于是我就用pip安装了一个seaborn
后来在调用
sns.load_dataset("iris")
的时候报了一堆错误
---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
d:\anaconda\envs\tf2.0.0rc1\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
d:\anaconda\envs\tf2.0.0rc1\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
d:\anaconda\envs\tf2.0.0rc1\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
d:\anaconda\envs\tf2.0.0rc1\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
d:\anaconda\envs\tf2.0.0rc1\lib\http\client.py in _send_output(self, message_body, encode_chunked)
1025 del self._buffer[:]
-> 1026 self.send(msg)
1027
d:\anaconda\envs\tf2.0.0rc1\lib\http\client.py in send(self, data)
965 if self.auto_open:
--> 966 self.connect()
967 else:
d:\anaconda\envs\tf2.0.0rc1\lib\http\client.py in connect(self)
1405
-> 1406 super().connect()
1407
d:\anaconda\envs\tf2.0.0rc1\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)
d:\anaconda\envs\tf2.0.0rc1\lib\socket.py in create_connection(address, timeout, source_address)
706 err = None
--> 707 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
708 af, socktype, proto, canonname, sa = res
d:\anaconda\envs\tf2.0.0rc1\lib\socket.py in getaddrinfo(host, port, family, type, proto, flags)
747 addrlist = []
--> 748 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
749 af, socktype, proto, canonname, sa = res
gaierror: [Errno 11004] getaddrinfo failed
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
<ipython-input-6-7001b965feec> in <module>
----> 1 iris = sns.load_dataset("iris")
d:\anaconda\envs\tf2.0.0rc1\lib\site-packages\seaborn\utils.py in load_dataset(name, cache, data_home, **kws)
447 os.path.basename(full_path))
448 if not os.path.exists(cache_path):
--> 449 urlretrieve(full_path, cache_path)
450 full_path = cache_path
451
d:\anaconda\envs\tf2.0.0rc1\lib\urllib\request.py in urlretrieve(url, filename, reporthook, data)
245 url_type, path = splittype(url)
246
--> 247 with contextlib.closing(urlopen(url, data)) as fp:
248 headers = fp.info()
249
d:\anaconda\envs\tf2.0.0rc1\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context)
220 else:
221 opener = _opener
--> 222 return opener.open(url, data, timeout)
223
224 def install_opener(opener):
d:\anaconda\envs\tf2.0.0rc1\lib\urllib\request.py in open(self, fullurl, data, timeout)
523 req = meth(req)
524
--> 525 response = self._open(req, data)
526
527 # post-process response
d:\anaconda\envs\tf2.0.0rc1\lib\urllib\request.py in _open(self, req, data)
541 protocol = req.type
542 result = self._call_chain(self.handle_open, protocol, protocol +
--> 543 '_open', req)
544 if result:
545 return result
d:\anaconda\envs\tf2.0.0rc1\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args)
501 for handler in handlers:
502 func = getattr(handler, meth_name)
--> 503 result = func(*args)
504 if result is not None:
505 return result
d:\anaconda\envs\tf2.0.0rc1\lib\urllib\request.py in https_open(self, req)
1358 def https_open(self, req):
1359 return self.do_open(http.client.HTTPSConnection, req,
-> 1360 context=self._context, check_hostname=self._check_hostname)
1361
1362 https_request = AbstractHTTPHandler.do_request_
d:\anaconda\envs\tf2.0.0rc1\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args)
1317 encode_chunked=req.has_header('Transfer-encoding'))
1318 except OSError as err: # timeout error
-> 1319 raise URLError(err)
1320 r = h.getresponse()
1321 except:
URLError: <urlopen error [Errno 11004] getaddrinfo failed>
仔细研究了一下,基本都是空指针问题,为什么空指针,都指向了打开文件的那部分空指针了
然后我就去看一下数据集,发现seaborn-data文件夹居然是空的,没这些文件当然空指针了
ps:我的所有通过pip安装的数据集,包括NMIST都是在用户文件夹中
我也不知道怎么设置别的地方,hhh
在github找到官方的seaborn-data
seaborn-data数据集
下载下来,放进那个文件夹中
好了,不报错了