I would like to import urllib to use the function 'request'. However, I encountered an error when trying to do so. I tried pip install urllib but still had the same error. I am using Python 3.6. Really appreciate any help.
i do import urllib.request using this code:
import urllib.request, urllib.parse, urllib.error
fhand = urllib.request.urlopen('data.pr4e.org/romeo.txt')
counts = dict()
for line in fhand:
words = line.decode().split()
for word in words:
counts[word] = counts.get(word, 0) + 1
print(counts)
but it gives me this error: ModuleNotFoundError: No Module named 'urllib.parse'; 'urllib' is not a package
urllib
is a standard library, you do not have to install it. Simply import urllib