Easy Weather App: Streamlit + Plotly + Open-Meteo
3 min readJul 14, 2024
By the end of this tutorial, you’ll have a functional app that provides weather forecasts for any location based on latitude and longitude inputs.
What You’ll Need
Before we dive into the code, ensure you have the following installed:
- Python 3.7 or higher
- Streamlit
- Plotly
- Requests
- Pandas
You can install these packages using pip:
pip install streamlit plotly requests pandas
Step 1: Setting Up the Project
Create a new directory for your project and navigate into it. Inside the directory, create a new Python file, e.g., weather_app.py
.
Step 2: Importing Required Libraries
At the top of your weather_app.py
file, import the necessary libraries:
import streamlit as st
import requests
import pandas as pd
import plotly.express as px
Step 3: Fetching Weather Data
We need a function to fetch weather data from the Open-Meteo API. Here’s how you can do it:
# Function to get weather forecast
def…