A comprehensive weather application built with Streamlit that provides real-time weather data, forecasts, and AI-powered predictions for cities worldwide.
weather_app/
│
├── main.py # Main application file
├── config.py # Configuration and API settings
├── styles.py # CSS styles and UI theming
├── city_search.py # City search and geocoding functionality
├── weather_api.py # Weather API integration
├── data_processor.py # Data processing and formatting
├── predictor.py # AI prediction models
├── weather_map.py # Interactive map components
├── ui_components.py # UI components and displays
├── requirements.txt # Python dependencies
└── README.md # This file
- 🌍 Global City Search: Search for any city worldwide with autocomplete suggestions
- 🌤️ Real-time Weather: Current weather conditions with detailed metrics
- 📈 5-Day Forecast: Interactive charts showing temperature, humidity, wind, and rain probability
- 🔮 AI Predictions: Machine learning-powered temperature trend predictions
- ⚖️ City Comparison: Compare weather conditions across multiple cities
- 🗺️ Interactive Maps: Visualize weather data on interactive world maps
- 📊 Weather Insights: Analyze weather patterns and trends
- 🎨 Modern UI: Beautiful, responsive design with smooth animations
- Python 3.8 or higher
- OpenWeatherMap API key (free at https://openweathermap.org/api)
Create a new directory and save all the provided files:
mkdir weather_app
cd weather_app
Save the following files in your directory:
main.py
config.py
styles.py
city_search.py
weather_api.py
data_processor.py
predictor.py
weather_map.py
ui_components.py
requirements.txt
pip install -r requirements.txt
- Get your free API key from OpenWeatherMap
- Open
config.py
- Replace the API_KEY value with your actual API key:
API_KEY = "your_actual_api_key_here"
streamlit run main.py
The application will open in your default web browser at http://localhost:8501
-
Search Cities:
- Type any city name in the search box
- Select from autocomplete suggestions
- Or choose from popular cities list
-
View Weather Data:
- Current conditions with temperature, humidity, wind speed
- 5-day forecast with interactive charts
- AI-powered temperature predictions
-
Compare Cities:
- Add multiple cities for comparison
- View side-by-side weather data
- Interactive comparison charts and maps
-
Navigate the Interface:
- Use tabs to switch between different chart views
- Hover over charts for detailed information
- Click on map markers for city details
API Key Problems:
- Make sure your API key is valid and active
- New keys need up to 2 hours to activate
- Check your API usage limits
Installation Issues:
- Ensure Python 3.8+ is installed
- Try upgrading pip:
pip install --upgrade pip
- Install dependencies one by one if batch installation fails
City Search Not Working:
- Check internet connection
- Verify API key in config.py
- Try searching with just city name (e.g., "London" instead of "London, UK")
Charts Not Displaying:
- Clear browser cache
- Check if all dependencies are installed
- Try refreshing the page
- Main application orchestration
- Session state management
- User interface coordination
- API configuration
- Cache settings
- API key validation
- OpenWeatherMap API integration
- Data fetching with caching
- Error handling
- Streamlit UI components
- Interactive charts and displays
- User input handling
- Machine learning predictions
- Weather pattern analysis
- Temperature trend forecasting
This application uses the OpenWeatherMap API:
- Current Weather Data: Real-time weather conditions
- 5-Day Forecast: Weather predictions every 3 hours
- Geocoding API: City search and coordinates
API Limits (Free Plan):
- 1,000 calls per day
- 60 calls per minute
- Data updates every 2 hours
To update the application:
- Replace the old files with new versions
- Update dependencies:
pip install -r requirements.txt --upgrade
- Restart the Streamlit application
If you encounter any issues:
- Check the troubleshooting section above
- Verify your API key and internet connection
- Ensure all dependencies are correctly installed
- Check the Streamlit documentation for UI-related issues
- Search Tips: Use simple city names for better results
- Performance: The app caches data for 5 minutes to improve speed
- Mobile: Works on mobile devices but desktop experience is recommended
- Multiple Cities: Add up to 10 cities for comparison for optimal performance
Built with ❤️ using Streamlit and OpenWeatherMap API