Home > Blockchain >  Python3 error : AttributeError: module 'urllib' has no attribute 'request'
Python3 error : AttributeError: module 'urllib' has no attribute 'request'

Time:11-26

I am trying to run a script in python3 (tried with 3.7.4 and 3.8.0) which uses urllib.request and urllib.error.

I tried importing in the following ways:

import urllib

and

from urllib import request

but in both the above cases I get error:

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

I haven't installed anything related to urllib as it comes with python3

Please suggest how should this be imported, thanks!

CodePudding user response:

Since urllib is a folder and request is a file inside urllib, you should use:

import urllib.request as request

CodePudding user response:

Worked with following import:

import urllib.request
  • Related