A desktop weather application built with Python and PyQt6. This application allows users to search for a city by name and view the current temperature along with a dynamic weather emoji representing the sky conditions.
- Real-Time Data: Fetches live weather data using the OpenWeatherMap API.
- Two-Step API : Utilizes the Geocoding API to convert city names into exact coordinates (lat/lon) before calling the Current Weather Data API.
- Dynamic UI: Features a clean, custom-styled graphical user interface built with PyQt6.
- Smart Emojis: Automatically updates the weather emoji (⛈️, 🌧️, ☀️, ☁️, etc.) based on the specific weather condition ID returned by the API.
- Error Handling: Comprehensive
try-exceptblocks andmatch-casestructures to handle HTTP errors (401, 404, 500, etc.), invalid city names, and connection timeouts gracefully without crashing.
- Python 3
- PyQt6 (GUI)
- Requests (HTTP library)
- Python-dotenv (Env management)
- uv (Fast Python package installer and resolver)
If you want to run this project locally, follow these steps:
1. Clone the repository:
2. Set up the API Key:
- Create a free account at [OpenWeatherMap] and generate an API key.
- Create a file named
.envin the root directory of the project. - Add your API key to the file like this:
WEATHER_API_KEY=your_api_key_here3. Install dependencies:
If you are using uv:
uv syncOr if you are using standard pip:
pip install -r requirements.txt4. Run the application:
If using uv:
uv run main.pyOr using standard
python main.py