module 'urllib' has no attribute 'urlopen'が出た場合

Pythonで
module 'urllib' has no attribute 'urlopen'
というエラーが出た場合の対処法。



urllib.requestを代わりに使おう

urllibの代わりにurllib.requestをimportする。
import urllib.request
urllib.request.urlopen(...)

参考

python - AttributeError: 'module' object has no attribute 'urlopen' - Stack Overflow
python - AttributeError: module 'urllib' has no attribute 'urlopen' - Stack Overflow