前提・実現したいこと
mnistを取得しようとして、エラーが発生しました。
発生している問題・エラーメッセージ
(base) -----------------------
Using TensorFlow backend.
Downloading data from https://s3.amazonaws.com/img-datasets/mnist.npz
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1317, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1229, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1275, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1224, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1016, in _send_output
self.send(msg)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 956, in send
self.connect()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1392, in connect
server_hostname=server_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 412, in wrap_socket
session=session
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 853, in _create
self.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 1117, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/utils/data_utils.py", line 113, in get_file
functools.partial(dl_progress, progbar=progbar))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
response = self._open(req, data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open
'_open', req)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1360, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1319, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test3.py", line 13, in <module>
(x_train, y_train), (x_test, y_test) = mnist.load_data()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/datasets/mnist.py", line 15, in load_data
path = get_file(path, origin='https://s3.amazonaws.com/img-datasets/mnist.npz')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keras/utils/data_utils.py", line 115, in get_file
raise Exception(error_msg.format(origin, e.errno, e.reason))
Exception: URL fetch failure on https://s3.amazonaws.com/img-datasets/mnist.npz: None -- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)
(base) ------------------------------
該当のソースコード
必要なライブラリのインポート
from keras import backend as K
from keras.datasets import mnist
import matplotlib.pyplot as plt
mnist データをダウンロード
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
画像データとラベルの要素数を表示
print("画像データの要素数", train_images.shape)
print("ラベルデータの要素数", train_labels.shape)
ラベルと画像データを表示
for i in range(0,10):
print("ラベル", train_labels[i])
plt.imshow(train_images[i].reshape(28, 28), cmap='Greys')
plt.show()
###ここに言語名を入力
Python3
試したこと
赤いエラーが表示されていないのですが、実行するとエラー(?)なので原因がつかめず、何度かKerasとmatplotlibがインストールされているかどうかを確認しました。
Keresをもう一度pip3でインストールをかけるとalreadyから始まる文がいくつも出て、matplotlibは違うコードで成功しているため、どちらも確実にインストールされていると思われます。
補足情報(FW/ツールのバージョンなど)
MacBook Pro, Python3 , VScode
ここにより詳細な情報を記載してください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/02 11:05
2019/05/02 11:10
2019/05/03 05:59
2019/05/03 06:01
2019/05/03 07:08
2019/05/03 07:10