See the world's weather 🌤 at home through your CLI window.
View weather and temperature information for different cities around the world right inside your CLI:
Follow the tutorial to Build This Weather CLI App with Python using only modules from Python's standard library.
To run this CLI app, you need a modern installation of Python >= 3.6.
Note: This app was developed on macOS for the Zsh shell. Your mileage with some of the color display and emojis may vary depending on your setup. On Windows, PowerShell on Windows Terminal displays the formatting reasonably well.
You also need an API key for OpenWeather's API. After signing up and generating your API key, add it to the secrets.ini
config file:
[openweathermap]
api_key = <YOUR-OPENWEATHERAPP-API-KEY>
Note: Make sure that secrets.ini
is not tracked by your version control system, to avoid leaking your API key to the public.
For more information on the OpenWeather API used in this CLI app, check out the documentation on the city name endpoint.
Once you're set up, you can call the weather CLI by running:
$ python weather.py <CITY_NAME> [-i]
For example, to get the current weather in Vienna, Austria, you can run the following command:
$ python weather.py Vienna
To display the temperature in Fahrenheit, you can add the optional -i
or --imperial
flag.
For more examples and usage, please refer to the associated Real Python tutorial.
To run and continue development on this CLI project, you need to have Python>=3.6 installed on your system.
- 0.1.0
- The first proper release
Martin Breuss – @martinbreuss – martin@realpython.com
Distributed under the MIT License.
https://github.com/martin-martin
- Fork it (https://github.com/realpython/materials/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request