【python】 proxy下でデータセットをダウンロードする

以下の設定を書く.

import urllib.request
# proxy の設定
proxy_support = urllib.request.ProxyHandler({'http' : 'http://***.***.***:port',
                                             'https': 'https://***.***.***:port'})
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)

これを事前に書けば

# CIFAR-10データセットをロード
from keras.datasets import cifar10
(X_train, y_train), (X_test, y_test) = cifar10.load_data()
print(X_train.shape, y_train.shape)
print(X_test.shape, y_test.shape)

でエラーを起こさない.