# How to use the Python\_weather function?

**URL:** <https://discuss.python.org/t/how-to-use-the-python-weather-function/61952>\
**Category:** Python Help\
**Tags:** documentation, help\
**Created:** [August 25, 2024, 11:14pm UTC](https://discuss.python.org/t/how-to-use-the-python-weather-function/61952 "2024-08-25T23:14:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trav88](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@Trav88](https://discuss.python.org/u/Trav88)\
**Post date:** [August 25, 2024, 11:14pm UTC](https://discuss.python.org/t/how-to-use-the-python-weather-function/61952/1 "2024-08-25T23:14:11Z")

</div>

Hello! I am relatively new to coding. I am trying to pull live weather data using import python\_weather, but i am not sure how to call the API through the code. Here is what I have so far. Any help would be greatly appreciated!

`import python_weather`  
`import asyncio`  
`import os`

```python
async def get_weather(city_name):
    async with python_weather.Client(unit=python_weather.IMPERIAL) as client:
        weather = await client.get(city_name)
        return weather

def parse_command(command):
    if "weather" in command:
        weather_description = asyncio.run(get_weather("Chicago"))
        query = "System information: " + str(weather_description)
        print(query)
        response = assist.ask_question_memory(query)
        done = assist.TTS(response)

```

---

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [August 26, 2024, 2:29am UTC](https://discuss.python.org/t/how-to-use-the-python-weather-function/61952/2 "2024-08-26T02:29:38Z")

</div>

async is not normally for beginners. Why are you using it? I see no reason here. Also, I don’t see where `assist` is defined.

(Please fix the formatting so that _all_ code is between one pair of backtick lines.)
