Skip to content

Latest commit

Β 

History

History
124 lines (93 loc) Β· 3.51 KB

README.md

File metadata and controls

124 lines (93 loc) Β· 3.51 KB

🌀️ PythonWeather

A beautiful desktop weather application built with Python that provides real-time weather information using the OpenWeatherMap API.

Features

  • 🌍 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

Requirements

  • Python 3.7 or higher
  • pip (Python package manager)

Installation

  1. Clone the repository

    git clone https://github.com/kenpario/PythonWeather.git
    cd PythonWeather
  2. Install dependencies

    pip install -r requirements.txt

    Or install manually:

    pip install PyQt5 requests python-dotenv
  3. Set up your API key

    • Create a .env file in the project root directory
    • Sign up for a free API key at OpenWeatherMap
    • Add your API key to the .env file:
      weather_api_key=your_api_key_here
      

Usage

Run the application:

python main.py
  1. Enter a city name in the input field
  2. Click "Get Weather" to fetch current weather data
  3. View the temperature, weather description, and visual emoji indicator

How It Works

The application:

  1. Accepts city input from the user via the GUI
  2. Queries the OpenWeatherMap API with the city name
  3. Parses the JSON response to extract weather data
  4. Converts temperature from Kelvin to Celsius
  5. Selects an appropriate emoji based on weather conditions
  6. Displays temperature, emoji, and description in the interface
  7. Handles errors gracefully with user-friendly messages

Error Handling

The app provides helpful error messages for common issues:

  • City not found - Invalid or non-existent city name
  • Invalid API key - Check your .env file configuration
  • Connection errors - Check your internet connection
  • Timeout errors - Request took too long
  • Server errors - OpenWeatherMap API server issues

Technologies Used

  • 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

Project Structure

PythonWeather/
β”œβ”€β”€ main.py              # Main application file
β”œβ”€β”€ .env                 # Environment variables (API key)
β”œβ”€β”€ .gitignore          # Git ignore file
└── README.md           # This file

Weather Emoji Reference

Weather Condition Emoji
Thunderstorm 🌩️
Drizzle 🌦️
Rain 🌧️
Snow ❄️
Mist/Fog 🌫️
Tornado πŸŒͺ️
Ash πŸŒ‹
Clear β˜€οΈ
Clouds ☁️

Tips

  • 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

License

This project is open source and available under the MIT License.

Contributing

Feel free to fork this repository and submit pull requests for any improvements!

Author

Created by kenpario