installing urllib in Python3.6 installing urllib in Python3.6 python-3.x python-3.x

installing urllib in Python3.6


urllib is a standard library, you do not have to install it. Simply import urllib


The corrected code is

import urllib.requestfhand = urllib.request.urlopen('http://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) 

running the code above produces

{'Who': 1, 'is': 1, 'already': 1, 'sick': 1, 'and': 1, 'pale': 1, 'with': 1, 'grief': 1}


urllib is a standard python library (built-in) so you don't have to install it. just import it if you need to use request by:

import urllib.request

if it's not work maybe you compiled python in wrong way, so be kind and give us more details.