I am trying to import urllib.request for python 2.7.10 on PyCharm 4.5.4 on Window 10 but getting the error "ImportError: No module named request".
I have also faced the same error and Googled to solve it.
urlib.request
is for Python 3.0.
You may use the code below:
import urllib
urllib.urlopen(url)
The urllib.request modules have been deprecated .. just use
import urllib
And for your function if you were earlier writing say
urllib.request.urlretrieve
Now you just write
urllib.urlretrieve
You'll get this error if you try running a python 3 file with python 2.
Try to use this in Python3
try:
x = urllib.request.urlopen('https://www.google.com/search?q=test')
print(x.read())
except Exception as e:
print(str(e))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With