AttributeError: 'module' object has no attribute 'request' AttributeError: 'module' object has no attribute 'request' python python

AttributeError: 'module' object has no attribute 'request'


The urllib module has been split into parts and renamed in Python 3 to urllib.request, urllib.parse, and urllib.error.


Import urllib.request instead of urllib.

import urllib.request


Interestingly, I noticed some IDE-depending behavior.

Both Spyder and PyCharm use the same interpreter on my machine : in PyCharm I need to do

import urllib.request

while in Spyder,

import urllib

does fine


If this is on PyCharm, as was mine, make sure your file name isn't urllib.py.