はじめに
いつもお世話になっております。
「pythonユーザのためのjupyter 実践 入門」という本で勉強しており、
gitからファイルを表示(import osのブロック)はできたのですが、
python上にanime.csvの.head()を表示させようとするとWinError10054と表示さてしまいます。
これを解決して問題なく機能するようにしたいです。
よろしくお願いします。
###環境
python3
jupyter notebook
IE バージョン 11.175
win10 ver1903 64ビット
プログラミング初心者
特に環境変数の設定などは、全く知識がないです。
python
1import os 2base_url = 'https://raw.github.com/practical-jupyter/sample-data/master/anime/' 3anime_csv = os.path.join(base_url, 'anime.csv') 4print(anime_csv) 5 6 7import pandas as pd 8 9anime_csv = os.path.join(base_url, 'anime.csv') 10pd.read_csv(anime_csv).head()
import pandas as pd 以下のコードを実行すると下記のエラーが出ます。
python
1 2--------------------------------------------------------------------------- 3ConnectionResetError Traceback (most recent call last) 4~\AppData\Local\Continuum\anaconda3\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args) 5 1316 h.request(req.get_method(), req.selector, req.data, headers, 6-> 1317 encode_chunked=req.has_header('Transfer-encoding')) 7 1318 except OSError as err: # timeout error 8 9~\AppData\Local\Continuum\anaconda3\lib\http\client.py in request(self, method, url, body, headers, encode_chunked) 10 1228 """Send a complete request to the server.""" 11-> 1229 self._send_request(method, url, body, headers, encode_chunked) 12 1230 13 14~\AppData\Local\Continuum\anaconda3\lib\http\client.py in _send_request(self, method, url, body, headers, encode_chunked) 15 1274 body = _encode(body, 'body') 16-> 1275 self.endheaders(body, encode_chunked=encode_chunked) 17 1276 18 19~\AppData\Local\Continuum\anaconda3\lib\http\client.py in endheaders(self, message_body, encode_chunked) 20 1223 raise CannotSendHeader() 21-> 1224 self._send_output(message_body, encode_chunked=encode_chunked) 22 1225 23 24~\AppData\Local\Continuum\anaconda3\lib\http\client.py in _send_output(self, message_body, encode_chunked) 25 1015 del self._buffer[:] 26-> 1016 self.send(msg) 27 1017 28 29~\AppData\Local\Continuum\anaconda3\lib\http\client.py in send(self, data) 30 955 if self.auto_open: 31--> 956 self.connect() 32 957 else: 33 34~\AppData\Local\Continuum\anaconda3\lib\http\client.py in connect(self) 35 1391 self.sock = self._context.wrap_socket(self.sock, 36-> 1392 server_hostname=server_hostname) 37 1393 38 39~\AppData\Local\Continuum\anaconda3\lib\ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session) 40 411 context=self, 41--> 412 session=session 42 413 ) 43 44~\AppData\Local\Continuum\anaconda3\lib\ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session) 45 852 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") 46--> 853 self.do_handshake() 47 854 except (OSError, ValueError): 48 49~\AppData\Local\Continuum\anaconda3\lib\ssl.py in do_handshake(self, block) 50 1116 self.settimeout(None) 51-> 1117 self._sslobj.do_handshake() 52 1118 finally: 53 54ConnectionResetError: [WinError 10054] 既存の接続はリモート ホストに強制的に切断されました。 55 56During handling of the above exception, another exception occurred: 57 58URLError Traceback (most recent call last) 59<ipython-input-2-5bda163a44af> in <module> 60 2 61 3 anime_csv = os.path.join(base_url, 'anime.csv') 62----> 4 pd.read_csv(anime_csv).head() 63 64~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision) 65 700 skip_blank_lines=skip_blank_lines) 66 701 67--> 702 return _read(filepath_or_buffer, kwds) 68 703 69 704 parser_f.__name__ = name 70 71~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds) 72 411 compression = _infer_compression(filepath_or_buffer, compression) 73 412 filepath_or_buffer, _, compression, should_close = get_filepath_or_buffer( 74--> 413 filepath_or_buffer, encoding, compression) 75 414 kwds['compression'] = compression 76 415 77 78~\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\io\common.py in get_filepath_or_buffer(filepath_or_buffer, encoding, compression, mode) 79 200 80 201 if _is_url(filepath_or_buffer): 81--> 202 req = _urlopen(filepath_or_buffer) 82 203 content_encoding = req.headers.get('Content-Encoding', None) 83 204 if content_encoding == 'gzip': 84 85~\AppData\Local\Continuum\anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 86 220 else: 87 221 opener = _opener 88--> 222 return opener.open(url, data, timeout) 89 223 90 224 def install_opener(opener): 91 92~\AppData\Local\Continuum\anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout) 93 523 req = meth(req) 94 524 95--> 525 response = self._open(req, data) 96 526 97 527 # post-process response 98 99~\AppData\Local\Continuum\anaconda3\lib\urllib\request.py in _open(self, req, data) 100 541 protocol = req.type 101 542 result = self._call_chain(self.handle_open, protocol, protocol + 102--> 543 '_open', req) 103 544 if result: 104 545 return result 105 106~\AppData\Local\Continuum\anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 107 501 for handler in handlers: 108 502 func = getattr(handler, meth_name) 109--> 503 result = func(*args) 110 504 if result is not None: 111 505 return result 112 113~\AppData\Local\Continuum\anaconda3\lib\urllib\request.py in https_open(self, req) 114 1358 def https_open(self, req): 115 1359 return self.do_open(http.client.HTTPSConnection, req, 116-> 1360 context=self._context, check_hostname=self._check_hostname) 117 1361 118 1362 https_request = AbstractHTTPHandler.do_request_ 119 120~\AppData\Local\Continuum\anaconda3\lib\urllib\request.py in do_open(self, http_class, req, **http_conn_args) 121 1317 encode_chunked=req.has_header('Transfer-encoding')) 122 1318 except OSError as err: # timeout error 123-> 1319 raise URLError(err) 124 1320 r = h.getresponse() 125 1321 except: 126 127URLError: <urlopen error [WinError 10054] 既存の接続はリモート ホストに強制的に切断されました。> 128 129 130
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/28 15:17
2019/07/28 23:25 編集
2019/07/29 03:59