I am trying to build a triviol Python script that will grab data from URL and save it onto the server. Concider the below code:
#!/usr/bin/python import pprint import json import urllib2 def getUSGS_json(): print "Fetch data from URL" fileName = 'data/usgsEarthquacks_12Hrs.json' url = 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson' data = urllib2.urlopen(url).read() if data: try: with open(fileName) as jsonGetData: filePut = open(fileName, 'w+') #add data filePut.write(data) filePut.close() j = json.load(jsonGetData) print j except Exception, e: print e raise else: pass finally: pass #end if #end getUSGS_json getUSGS_json() Upon running the script I get the following errors:
Traceback (most recent call last): File "geoJsonFetch.py", line 4, in import urllib2 File "/usr/local/lib/python2.7/urllib2.py", line 94, in import httplib File "/usr/local/lib/python2.7/httplib.py", line 79, in import mimetools File "/usr/local/lib/python2.7/mimetools.py", line 6, in import tempfile File "/usr/local/lib/python2.7/tempfile.py", line 32, in import io as _io File "/usr/local/lib/python2.7/io.py", line 51, in import _io ImportError: /usr/local/lib/python2.7/lib-dynload/_io.so: undefined symbol: PyUnicodeUCS2_Replace I have looked around on SO and found similar errors like this one, but they do not seem to get at the heart of why some people are able to get this code to run and I am not. They all seem to be dealing with issues concerning developing in C and using Python to access that C module.
Is it the Ubuntu version, Python version??
Thank you.