csparpa / pyowm

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

AttributeError: 'Observation' object has no attribute 'observation' #363

Closed deefrawley closed 3 years ago

deefrawley commented 3 years ago

Code taken directly from the online documentation:

from pyowm.owm import OWM

owm = OWM("XXX MY KEY XXX")

mgr = owm.weather_manager()

pressure_dict = mgr.weather_at_place('Berlin,DE').observation.pressure
pressure_dict['press']
pressure_dict['sea_level']

gives the following error

Traceback (most recent call last):
  File ".\owtest.py", line 7, in <module>
    pressure_dict = mgr.weather_at_place("Berlin,DE").observation.pressure
AttributeError: 'Observation' object has no attribute 'observation'

Happens for the rainfall example as well. Someone has also posted this on Stack Overflow

csparpa commented 3 years ago

@deefrawley thanks for pointing this out, it's a bug in the docs

The line pressure_dict = mgr.weather_at_place('Berlin,DE').observation.pressure

should be

pressure_dict = mgr.weather_at_place('Berlin,DE').weather.pressure

csparpa commented 3 years ago

Refer to: https://stackoverflow.com/questions/65376056/pyowm-observation-object-has-no-attribute-observation/65484048#65484048

deefrawley commented 3 years ago

No worries - I guess a documentation fix is much easier than code fix :)

csparpa commented 3 years ago

Fixed with 0eb016b29bda31f04284db3817d507de06f4a5f6