I'm following this post to calculate distance matrix so this is the code snippet
import urllib.request
from urllib.parse import quote
import urllib.parse
import simplejson, urllib
import urllib.request
orig_coord = 19.12,19.45
dest_coord = 19.10,19.50
url = 'http://maps.googleapis.com/maps/api/distancematrix/json?origins=' + urllib.quote_plus(orig_coord)+ '&destinations=' + urllib.quote_plus(dest_coord) + '&mode=driving&language=en-EN&sensor=false'
#url = "http://maps.googleapis.com/maps/api/distancematrix/json?origins={0}&destinations={1}&mode=driving&language=en-EN&sensor=false".format(str(orig_coord),str(dest_coord))
#result= simplejson.load(urllib.urlopen(url))
result=urllib.request.urlopen(url)
driving_time = result['rows'][0]['elements'][0]['duration']['value']
I had tried these two method(other one with comments) but it never worked though, now with these code I get the error
runfile('C:/Users/admin/.spyder-py3/temp.py', wdir='C:/Users/admin/.spyder-py3')
Traceback (most recent call last):
File "<ipython-input-22-30ed5be6f1c7>", line 1, in <module>
runfile('C:/Users/admin/.spyder-py3/temp.py', wdir='C:/Users/admin/.spyder-py3')
File "C:\Users\admin\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Users\admin\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/admin/.spyder-py3/temp.py", line 16, in <module>
url = 'http://maps.googleapis.com/maps/api/distancematrix/json?origins=' + urllib.quote_plus(orig_coord)+ '&destinations=' + urllib.quote_plus(dest_coord) + '&mode=driving&language=en-EN&sensor=false'
AttributeError: module 'urllib' has no attribute 'quote_plus'