Solving attributeerror: module ‘urllib’ has no attribute ‘request’

Using urllib in Python 3 is an error like this:

Traceback (most recent call last):
  File "*.py", line 34, in <module>
    html_page = get(URL, req_header)
  File "*.py", line 18, in get_HTML
    request = urllib.request.Request(url, headers=req_header)
AttributeError: module 'urllib' has no attribute 'request'

An error code

import urllib
request = urllib.request.Request(url, headers=req_header)
html = urllib.request.urlopen(request).read()
print (html)

Error reason:
in the Python AttributeError errors there are two kinds of main reason:
1.
2. File with same name exists in project directory

> port urllib.request <>ode>
>

import urllib
import urllib.request
request = urllib.request.Request(url, headers=req_header)
html = urllib.request.urlopen(request).read()
print (html)

Read More: