🌦️ Weather Forecast Python CLI A Python command-line application that fetches and displays current weather information and a 5-day forecast for any city using the OpenWeatherMap API.
📌 Features
- Get current weather details (temperature, humidity, wind speed, description)
- 5-day forecast (optional enhancement)
- Handles errors gracefully
- Extendable with GUI and data logging options
🛠️ Setup Instructions
-
Environment Setup Ensure you have Python installed, and install the required package using: pip install requests
-
Getting an API Key
- Sign up at OpenWeatherMap
- Go to your dashboard and generate a free API key
🌐 API Details Current Weather Endpoint: https://api.openweathermap.org/data/2.5/weather?q={city_name}&appid={API_key}&units=metric
Replace:
- {city_name} with the desired city
- {API_key} with your OpenWeatherMap API key
- Use units=metric for Celsius or units=imperial for Fahrenheit
🧪 Project Structure Core Steps:
- Prompt user for a city
- Fetch weather data using OpenWeatherMap
- Parse JSON response
- Display weather in readable format
- Handle errors (invalid city, network issues)
🚀 Enhancements (Optional)
- 🔄 5-Day Forecast: Use the /forecast endpoint to show extended weather info
- 🌡️ Unit Switching: Let users choose between Celsius and Fahrenheit
- 💾 Weather History: Log recent weather lookups in a file/database
- 🖥️ GUI Version: Use Tkinter or PyQt to build an interactive interface
- 🛠️ Error Feedback: Provide detailed messages like “City not found” or “Invalid API key”