2
當我運行下面的代碼403地理編碼
from googlemaps import GoogleMaps
gmaps = GoogleMaps('my api key here')
address = 'Constitution Ave NW & 10th St NW, Washington, DC'
lat, lng = gmaps.address_to_latlng(address)
print lat, lng
但禁止錯誤,當我運行此我得到以下錯誤
File "map.py", line 4, in <module>
lat, lng = gmaps.address_to_latlng(address)
File "/usr/local/lib/python2.7/dist-packages/googlemaps-1.0.2-py2.7.egg/googlemaps.py", line 310, in address_to_latlng
return tuple(self.geocode(address)['Placemark'][0]['Point']['coordinates'][1::-1])
File "/usr/local/lib/python2.7/dist-packages/googlemaps-1.0.2-py2.7.egg/googlemaps.py", line 259, in geocode
url, response = fetch_json(self._GEOCODE_QUERY_URL, params=params)
File "/usr/local/lib/python2.7/dist-packages/googlemaps-1.0.2-py2.7.egg/googlemaps.py", line 50, in fetch_json
response = urllib2.urlopen(request)
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 406, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 519, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 444, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 527, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden
任何想法如何解決這個問題?我無法想出任何方式。
你是以純客戶端還是通過某些wamp服務器運行它? –
沒有wamp服務器...通過命令行運行它 –