我尝试从书“ Foundation of Python Network Programming ”Apres学习python网络编程,
首先我们了解' virtualenv ' and I install virtualenv , try to get ' googlemap package ' and try using simple program call ' search1':
#!/usr/bin/env python
# Foundations of Python Network Programming - Chapter 1 - search1.py
from googlemaps import GoogleMaps
address = '207 N. Defiance St, Archbold, OH'
print GoogleMaps().address_to_latlng(address)
之后我尝试运行它,
- the result from the book is
$ python search1.py
(41.5228242,-84.3063479)
- the result I get is error liket this
Traceback(最近一次调用最后一次):
文件“search1.py”,第6行,打印GoogleMaps() . address_to_latlng(地址)
在address_to_latlng中输入文件“/home/administrator/gmapenv/local/lib/python2.7/site-packages/googlemaps.py”,第310行
return tuple(self.geocode(address)['Placemark'] [0] ['Point'] ['coordinates'] [1 :: - 1])
文件“/home/administrator/gmapenv/local/lib/python2.7/site-packages/googlemaps.py”,第259行,地理编码
url,response = fetch_json(self._GEOCODE_QUERY_URL,params = params)
文件“/home/administrator/gmapenv/local/lib/python2.7/site-packages/googlemaps.py”,第50行,fetch_json response = urllib2.urlopen(request)
文件“/usr/lib/python2.7/urllib2.py”,第127行,在urlopen中返回_opener.open(url,data,timeout)
文件“/usr/lib/python2.7/urllib2.py”,第407行,打开响应= meth(req,response)
文件“/usr/lib/python2.7/urllib2.py”,第520行,http_response'htt',请求,响应,代码,消息,hdrs)
文件“/usr/lib/python2.7/urllib2.py”,第445行,错误返回self._call_chain(* args)
文件“/usr/lib/python2.7/urllib2.py”,第379行,在_call_chain中结果= func(* args)
文件“/usr/lib/python2.7/urllib2.py”,第528行,在http_error_default中引发HTTPError(req.get_full_url(),代码,msg,hdrs,fp)urllib2.HTTPError:HTTP错误403:禁止
是什么造成了这个错误,因为我像书中一样一步一步地跑下去