import csv
from geopy import geocoders
import time
g = geocoders.Google()
spamReader = csv.reader(open('locations.csv', 'rb'), delimiter='\t', quotechar='|')
f = open("output.txt",'w')
for row in spamReader:
a = ', '.join(row)
#exactly_one = False
time.sleep(1)
try:
place, (lat, lng) = g.geocode(a)
except (ValueError, geocoders.google.GQueryError, geocoders.google.GeocoderResultError, geocoders.google.GBadKeyError, geocoders.google.GTooManyQueriesError):
#print("Error: geocode failed on input %s with message %s"%(a, error_message)
f.write("exception")
continue
b = str(place) + "," + "[" + str(lat) + "," + str(lng) + "]" + "\n"
print b
f.write(b)
The code I have above works great from the command prompt. I am wondering why when I try to run the script through Eclipse that I keep getting the "Unresolved import: geopy". I have tried to add it somehow under Project->properties->PYTHONPATH but I am having a bear of time finding out how to get Eclipse to recognize the fact that Geopy is installed to 'C:\Python27\Lib\site-packages\geopy-0.94.2-py2.7.egg'. My version of Eclipse is Juno running on Windows 7 with the JDK7u4 powering it. What should I do about this problem?