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 code> 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:
- Attributeerror: the solution of module ‘urllib’ has no attribute ‘quote’
- Solving attributeerror: module ‘Matplotlib’ has no attribute ‘artist’
- Solving attributeerror: module ‘Matplotlib’ has no attribute ‘plot‘
- [error] attributeerror: module ‘SIP’ has no attribute ‘setapi‘
- AttributeError: module ‘os’ has no attribute ‘mknod’
- Attributeerror: ‘module’ object has no attribute ‘handlers’ — Python sub module import problem
- AttributeError: module ‘torch’ has no attribute’_six’ [The problem is solved after restart]
- AttributeError:module“seaborn” has no attribute “lineplot”
- AttributeError: module ‘scipy.misc’ has no attribute ‘imread’
- AttributeError:module ‘seaborn‘ has no attribute ‘tsplot‘
- AttributeError: module ‘keras.backend‘ has no attribute ‘eager‘
- AttributeError: module ‘numpy‘ has no attribute ‘getbuffer‘
- AttributeError: module…ops‘ has no attribute ‘_TensorLike‘, ValueError: `updates` argument..eager
- Attributeerror: module “Seaborn” has no attribute “lineplot”
- AttributeError: module ‘onnxruntime‘ has no attribute ‘InferenceSession‘
- AttributeError: module ‘os‘ has no attribute ‘fork‘
- Solve the problem of attributeerror: module ‘SciPy’ has no attribute ‘Stats’
- AttributeError: module ‘onnxruntime‘ has no attribute ‘InferenceSession‘
- AttributeError: module ‘sacrebleu‘ has no attribute ‘compute_bleu‘
- Tensorflow error: attributeerror: module ‘tensorflow’ has no attribute ‘unpack’ (‘pack ‘)