ZeevG / python-forecast.io

A thin Python Wrapper for the Dark Sky (formerly forecast.io) weather API
http://zeevgilovitz.com/python-forecast.io/
Other
424 stars 88 forks source link

Json error in python 3. #31

Closed derekriemer closed 9 years ago

derekriemer commented 9 years ago

When using python 3 with this library, I get this error. Traceback (most recent call last): File "C:\Users\Derek Riemer\Google Drive\python\weather\weather.py", line 59, in args.func(args) File "C:\Users\Derek Riemer\Google Drive\python\weather\weather.py", line 12, in getWeather forecast.start(location.get('lat'), location.get('lng'), args.forecast) File "C:\Users\Derek Riemer\Google Drive\python\weather\forecast.py", line 103, in start forecast = forecastio.load_forecast(api_key, lat, lng) File "C:\Python34\lib\site-packages\forecastio\api.py", line 41, in load_forecast return manual(baseURL, callback=callback) File "C:\Python34\lib\site-packages\forecastio\api.py", line 51, in manual return get_forecast(requestURL) File "C:\Python34\lib\site-packages\forecastio\api.py", line 61, in get_forecast json = forecastio_reponse.json() File "C:\Python34\lib\site-packages\requests\models.py", line 819, in json return json.loads(self.text, **kwargs) File "C:\Python34\lib\jsoninit.py", line 318, in loads return _default_decoder.decode(s) File "C:\Python34\lib\json\decoder.py", line 343, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Python34\lib\json\decoder.py", line 361, in raw_decode raise ValueError(errmsg("Expecting value", s, err.value)) from None ValueError: Expecting value: line 1 column 1 (char 0)

I get the same error in django where I am playing around with weather data on a website. I dug into this a bit and I can't quite pinpoint any reason why this shouldn't work. Some people have had this error before on stack overflow, but I didn't really find a cure for the issue there, besides the possibility of malformed json. it works fine with python2, but I didn't see anything about which versions of python it should work with.

ZeevG commented 9 years ago

Looks like there were some problems decoding the json response. This could have been caused by a problem with the forecast.io http API or user error. Either way, I have included a line which should alert you to these sort of situations more clearly in the latest version 1.3.4