VOOZH about

URL: https://www.geeksforgeeks.org/python/get-live-weather-desktop-notifications-using-python/

⇱ Get Live Weather Desktop Notifications Using Python - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Get Live Weather Desktop Notifications Using Python

Last Updated : 8 Jun, 2026

Desktop notifications provide a quick way to receive real-time information without opening an application. In this project, we'll build a Python script that fetches live weather data for a city using the Open-Meteo API and displays it as a desktop notification. This program:

  • Automatically finds the latitude and longitude of the given city.
  • Fetches real-time weather information without requiring an API key.
  • Displays the weather details directly on your desktop as a notification.

How the Weather Notification System Works

  • Accept a City Name: The program uses a city name to identify the desired location.
  • Fetch Coordinates: The Open-Meteo Geocoding API converts the city name into latitude and longitude values.
  • Retrieve Weather Data: The Open-Meteo Weather API uses these coordinates to fetch current weather information.
  • Extract Key Details: Temperature and wind speed are extracted from the API response.
  • Display Notification: The weather details are shown as a desktop notification.

Modules Needed

In this script, we are going to use these libraries libraries

  • requests: For sending HTTP requests and fetching data from APIs.

pip install requests

  • plyer: For displaying desktop notifications across different operating systems.

pip install plyer

Step-by-Step Implementation

Step 1: Import the Required Modules

Step 2: Get the Coordinates of the City

We’ll use the Open-Meteo Geocoding API to convert a city name into its latitude and longitude. We can change the city name to our liking.

Explanation:

  • geo_params: Dictionary with search parameters (name of the city, count as number of results).
  • requests.get(geo_url, params=geo_params): Sends a GET request to the geocoding API with parameters.
  • .json(): Converts the API response from JSON format into a Python dictionary.

Step 3: Fetch Current Weather Data

If the city exists, we’ll use its coordinates to get temperature and wind speed from the Open-Meteo Weather API.

Output: We can see the raw data that we fetched in the terminal.

👁 weather_info
Weather info

Explanation:

  • lat & lon: Extract latitude and longitude from the API response.
  • weather_params: Contains coordinates and tells API to return only current weather.
  • requests.get(weather_url, params=weather_params): Fetches weather details for the city.

Step 4: Display the Notification

Once we have the weather data, we’ll show it on the desktop.

Explanation:

  • temp & wind: Extract temperature and wind speed from the API response.
  • weather_info: Format weather data as a readable string.
  • notification.notify(...): Shows the weather info in a desktop popup.
  • timeout=5: Notification stays visible for 5 seconds.

Complete Code

Let's run the script to get the current weather information for "New York" city:

Output:

👁 weather_info_new_york
Live Weather Info for "New York"

Let's try to fetch info for "Delhi" city.

Output:

👁 weather_info_delhi
Live Weather Info for "Delhi"
Comment