1

I am trying to use World Weather Online data. In the instructions, it is given that I need to use pywwo package. However when I run firstly, pip install pywwo it gives me `invalid syntax error even there is not. How can I handle it? thanks.

2 Answers2

1

I don't think pywwo works anymore. I am using pyowm, instead: https://pyowm.readthedocs.io/en/latest/. You will need an API key; follow this to get one: https://openweathermap.org/appid.

You can then write a function to get temperature like so:

def get_temp(zipcode:str)->int:
    """function to get weather using zipcode through pyOWM
    Arguments:
        zipcode {str} -- given by the user
    Returns:
        int -- temperature in fahrenheit returned by pyOWM
                for the current zipcode at the current time
    """
    owm = pyowm.OWM('YOUR API KEY GOES HERE')  # API key
    observation = owm.weather_at_zip_code(zipcode, "us")
    current_weather = observation.get_weather()
    temperature = current_weather.get_temperature('fahrenheit')['temp']
    return temperature
oamandawi
  • 405
  • 5
  • 15
  • thank you but it did not work either. does `pip install pyowm==2.7` work for you? – Şeyda Aydin Mar 11 '20 at 01:25
  • Please edit your question to specify that you are using Python 2.7. This works on python3 with just ```pip install pyowm```. In addition, if you want to install the package using pip for python2.7 you need to use ```pip2.7 install pyowm```. Check: https://stackoverflow.com/questions/2812520/dealing-with-multiple-python-versions-and-pip – oamandawi Mar 11 '20 at 01:49
  • Also, note that "Official support for Python 2 will be discontinued starting from January, 1st 2020." So, you should consider upgrading. – oamandawi Mar 11 '20 at 01:51
-1

You can git clone the repository and them import to your project.

I read the documentation and didn't find about the pip. Try the way above.

Jovani
  • 27
  • 4