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:

sudo apt-get install weather-util

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:

weather jfk


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:

weather egll

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:

weather 94110

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

weather 'new york'


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:

weather 'new york city central park'

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:

weather -f lax



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.

weather --info 20560

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:

nano ~/.weatherrc

Add these lines:

description = The Smithsonian Institution
metar =

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:

weather smithsonian


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.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox