A beautiful desktop weather application built with Python that provides real-time weather information using the OpenWeatherMap API.
- π Real-time Weather Data - Get current weather conditions for any city worldwide
- π¨ Intuitive GUI - Clean and user-friendly desktop interface built with PyQt5
- π‘οΈ Temperature Display - Shows temperature in Celsius with detailed weather descriptions
- π Weather Emojis - Visual weather indicators with contextual emojis (π©οΈ π§οΈ βοΈ βοΈ etc.)
β οΈ Error Handling - Comprehensive error messages for invalid inputs and connection issues- π Secure API Key Management - Uses environment variables for secure API key storage
- Python 3.7 or higher
- pip (Python package manager)
-
Clone the repository
git clone https://github.com/kenpario/PythonWeather.git cd PythonWeather -
Install dependencies
pip install -r requirements.txt
Or install manually:
pip install PyQt5 requests python-dotenv
-
Set up your API key
- Create a
.envfile in the project root directory - Sign up for a free API key at OpenWeatherMap
- Add your API key to the
.envfile:weather_api_key=your_api_key_here
- Create a
Run the application:
python main.py- Enter a city name in the input field
- Click "Get Weather" to fetch current weather data
- View the temperature, weather description, and visual emoji indicator
The application:
- Accepts city input from the user via the GUI
- Queries the OpenWeatherMap API with the city name
- Parses the JSON response to extract weather data
- Converts temperature from Kelvin to Celsius
- Selects an appropriate emoji based on weather conditions
- Displays temperature, emoji, and description in the interface
- Handles errors gracefully with user-friendly messages
The app provides helpful error messages for common issues:
- City not found - Invalid or non-existent city name
- Invalid API key - Check your
.envfile configuration - Connection errors - Check your internet connection
- Timeout errors - Request took too long
- Server errors - OpenWeatherMap API server issues
- PyQt5 - GUI framework for cross-platform desktop applications
- requests - HTTP library for API calls
- python-dotenv - Environment variable management
- OpenWeatherMap API - Real-time weather data source
PythonWeather/
βββ main.py # Main application file
βββ .env # Environment variables (API key)
βββ .gitignore # Git ignore file
βββ README.md # This file
| Weather Condition | Emoji |
|---|---|
| Thunderstorm | π©οΈ |
| Drizzle | π¦οΈ |
| Rain | π§οΈ |
| Snow | βοΈ |
| Mist/Fog | π«οΈ |
| Tornado | πͺοΈ |
| Ash | π |
| Clear | βοΈ |
| Clouds | βοΈ |
- The app requires an active internet connection
- Free OpenWeatherMap API key has rate limits
- Temperature is displayed in Celsius
- Works on Windows, macOS, and Linux
This project is open source and available under the MIT License.
Feel free to fork this repository and submit pull requests for any improvements!
Created by kenpario