csparpa / pyowm

A Python wrapper around the OpenWeatherMap web API
https://pyowm.readthedocs.io
MIT License
791 stars 175 forks source link

ParseResponseError: Exception in parsing OWM web API response #224

Closed RaenonX closed 6 years ago

RaenonX commented 6 years ago

I got this error when I use the coordinates to try to get the weather data: Reason: pyowm.webapi25.forecastparser: impossible to read location info from JSON data

Coordinates is

latitude: -55.776573
longitude: 90.163473
csparpa commented 6 years ago

Hi @RaenonX it might be that the OWM API is temporarily returning badly formatted JSON data (this happens seldom and usually is fixed upstream). But, it might also be that the change in the JSON format is voluntary and here to stay (and then we need to fix PyOWM accordingly)

Did you try to change the geocoords and see if you get the same error? Also, did you repeat the call after a while? You get the sme error?

csparpa commented 6 years ago

@RaenonX

latitude = -55.776573
longitude = 90.163473
fc = owm.daily_forecast_at_coords(latitude, longitude)
tomorrow = pyowm.timeutils.tomorrow()
fc.will_be_sunny_at(tomorrow)
print(fc.get_forecast().get_location())

that actually works quite well to me

Did you try to repeat the call?

RaenonX commented 6 years ago

I am not at home now. I will try to repeat that codes after I go back home.

By the way, the function that I used and throws the error is three_hours_forecast_at_coords (latitude, longitude).get_forecast()

On Dec 19, 2017 4:09 AM, "Claudio Sparpaglione" notifications@github.com wrote:

@RaenonX https://github.com/raenonx

latitude = -55.776573 longitude = 90.163473 fc = owm.daily_forecast_at_coords(latitude, longitude) tomorrow = pyowm.timeutils.tomorrow() fc.will_be_sunny_at(tomorrow)print(fc.get_forecast().get_location())

that actually works quite well to me

Did you try to repeat the call?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/csparpa/pyowm/issues/224#issuecomment-352543642, or mute the thread https://github.com/notifications/unsubscribe-auth/ARlt39EtbIjMHRFp6Zh6_GgD_2gaanhGks5tBsZlgaJpZM4RFMp7 .

csparpa commented 6 years ago

Thanks.

That's a bug! The JSON from the API has changed but the Location parser is not robust enough to return a "Null object" for the location bound to the forecast.

Bug is in lines: https://github.com/csparpa/pyowm/blob/1169d52e36ccf6aaa3c5777670700d292cc0982c/pyowm/webapi25/location.py#L187 and https://github.com/csparpa/pyowm/blob/1169d52e36ccf6aaa3c5777670700d292cc0982c/pyowm/webapi25/location.py#L188

RaenonX commented 6 years ago

Haha, thanks for fixing the bug :)

On Dec 19, 2017 5:37 AM, "Claudio Sparpaglione" notifications@github.com wrote:

Thanks.

That's a bug! The JSON from the API has changed but the Location parser is not robust enough to return a "Null object" for the location bound to the forecast.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/csparpa/pyowm/issues/224#issuecomment-352565510, or mute the thread https://github.com/notifications/unsubscribe-auth/ARlt3zEU9F-HK3PaIdzqOSHNsh3BFq8_ks5tBtssgaJpZM4RFMp7 .

csparpa commented 6 years ago

Fixed by https://github.com/csparpa/pyowm/commit/eb4ae017030079d57400ee8d4fb2f6a8802b8f5c