You did not import the name urlopen
.
Since you are using python3, you'll need urllib.request
:
from urllib.request import urlopen
req = urlopen(...)
or explicitly referring to the request module
import urllib.request
req = request.urlopen(...)
in python2 this would be
from urllib import urlopen
or use urllib.urlopen
.
Note: You are also overriding the name json which is not a good idea.