I have the following code and i tried all i could find on stackoverflow but nothing worked. Here is the 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)
And the error: ModuleNotFoundError: No module named 'urllib.request'; 'urllib' is not a package
do you have urllib installed? if not try to install it like this : pip install urllib3