Python 3.5.1 urllib has no attribute request Python 3.5.1 urllib has no attribute request python python

Python 3.5.1 urllib has no attribute request


According to this, you have to use the following:

import urllib.request

The reason is:

With packages, like this, you sometimes need to explicitly import thepiece you want. That way, the urllib module doesn't have to loadeverything up just because you wanted one small part.


Use this way

import urllib.requesturllib.request.urlopen('http://216.58.192.142',timeout=1)


In python 3.6.x this worked for me, this way I did not have to change the code at all:

import urllib.request as urllib