Get Weather Forecasts on Raspberry Pi

It seems like people have always been fascinated by the weather and of course having a reasonably accurate forecast for your area is very useful when it comes to planning days out and other activities. Weather forecast information can be found in a whole variety of places including on the web and on most smartphones and tablets. But you can also get the weather forecast from the command line of your Raspberry Pi using the “weather” utility.

Weather can be installed from the official Raspbian repositories:

The “weather” utility works by retrieving weather conditions and forecast information from METARs (Meteorological Aerodrome Reports), from NOAA (the USA National Oceanic and Atmospheric Administration) and NWS (the USA National Weather Service). This does make the the tool very USA-centric, however global locations are available where there are international airports.

The simplest way to get the weather conditions is to use the ICAO code for the nearest airport. So to get the weather at the Kennedy International Airport in New York type:


The full ICAO code for Kennedy International is actually “KJFK” (as all airports in the contiguous United States start with K) but the three letter variants work as well for airports in the USA, i.e. “DFW”, “LAX” and “ATL” etc. But for international airports, the full ICAO code must be used. So London Heathrow is “EGLL”, Paris Charles de Gaulle is “LFPG” and Schiphol in Amsterdam is “EHAM” and so on.

To see the conditions at London Heathrow, use:

It is also possible to lookup the weather conditions using a ZIP code. Included with “weather” is a ZIP code list along with information about the nearest weather station. Unfortunately this is only for the USA and doesn’t work internationally, but the ZIP information does cover the whole of the USA. For example, the Linux Foundation has its headquarters in San Francisco, California, and has a ZIP code of 94110. You can get the weather conditions there using:

You can also use place names to get weather information but you need to be quite specific. Try the following:


weather” will report that the search is too ambiguous and it will return at least ten results including “New York township – MO”, “New York City – NY” and “New York Mills city – MN” plus La Guardia International Airport.

But if you are more specific the conditions can be reported. Try:

You can also get a seven day forecast by using the “-f” option. To get the forecast for the area around Los Angeles International Airport, use:



You may have noticed that getting the weather conditions can sometimes take a few minutes, especially when searching by name. This isn’t because of a delay in retrieving the information on the Internet but rather because the “weather” utility needs to search through its lists of airport names, place names and zip codes. Since this information isn’t stored in a database, but rather as lists of text, searching it can be slow.

To speed it up, you can define an alias in “weather's” configuration file that already contains the information needed for the utility to directly access the Internet for the data.

First you need to find the name of the nearest weather station. To do this use the “--info” option which will give more details about where the weather information is coming from. Here is a search for the ZIP code 20560 which is the ZIP code of the Smithsonian in Washington, DC.

The output shows that the weather station being used is actually the Washington National Airport which is just 2.5 miles away. The code for that airport is “kdca”.

Create a weather configuration file (called .weatherrc) in your home directory:

Add these lines:

Note: The “metar = http…” information should all be on one line.

Now exit and save the file by pressing “Ctrl + X” and confirming the save. 

To get the weather conditions for the Smithsonian, just type:


The reply should be fairly quick as the utility now has the information it needs to fetch the data without trawling through its lists.

Multiple aliases can be added to the “.weatherrc” file; you just need to change the last part of the “metar” information to the correct weather station.

Why not give “weather” a try, and if you have any questions please feel free to ask them in the comments.

Gary Sims

Gary has been a technical writer, author and blogger since 2003. He is an expert in open source systems (including Linux), system administration, system security and networking protocols. He also knows several programming languages, as he was previously a software engineer for 10 years. He has a Bachelor of Science in business information systems from a UK University.


  1. Tried this, and it all works for “K” codes. My closest of this type was K9MN (St. Mary’s Hospital). The –info for my zip also shows MNZ087, but trying this in the metar string yields an error of 404: not found. How would I use this other code (which is closer to home than St. Mary’s)?

    1. The metar line for the .weatherrc should be:

      “metar =”

      Without the quotes and all on one line.

  2. I’m always on the lookout for new weather sites that can provide up to date information. this has the three major weather orgs in the states, plus International Airports from around the world. I find them the best for up-to-date weather and forecasts.

  3. Hello, Trying to get YYT to show, (St. John’s International airport) but no luck. not sure if there is any additional configuration that needs to be done other then basic installation

  4. How would I take the weather information and save it to a text file? I would like to display it on my security cams in Blue Iris. I have an arduino displaying a local reading and would like to use this raspberry pi to do a more in depth report.

    Thank you

    1. If you type:

      weather lax > lax.txt

      Then the output from the weather command will be redirected to the lax.txt file.

      I hope that helps, Gary.

  5. It works great, however when I try to call it through os.system in Python, it freezes. Any idea why?

    Thanks in advance

Comments are closed.