Re: Hi! i need some help with a program in python on Raspberry pi3.
On Friday, April 14, 2017 at 3:27:29 PM UTC+1, Kasper wrote: > every time i run the program i get this messeage: > > Traceback (most recent call last): > File "smartmirror.py", line 159, in get_weather > temprature2 = "%S%S" % (str(int(weather_obj['currently']['temperature'])), > degree_sign) > KeyError: 'currently' > Error: 'currently'. Cannot get weather. > > How do i fix that? > > Here is the program: > > r = requests.get(weather_req_url) > weather_obj = json.loads(r.text) > > degree_sign= u'\N{DEGREE SIGN}' > temperature2 = "%s%s" % > (str(int(weather_obj['currently']['temperature'])), degree_sign) Find the correct name for the key by printing out `weather_obj`. At least I think so, as the line above does not match the line that you've given. Kindest regards. Mark Lawrence. -- https://mail.python.org/mailman/listinfo/python-list
Re: Hi! i need some help with a program in python on Raspberry pi3.
On 4/14/2017 10:27 AM, Kasper wrote: every time i run the program i get this messeage: Traceback (most recent call last): File "smartmirror.py", line 159, in get_weather temprature2 = "%S%S" % (str(int(weather_obj['currently']['temperature'])), degree_sign) KeyError: 'currently' Error: 'currently'. Cannot get weather. How do i fix that? Use a valid key for weather_obj. Check doc or add print(list(weather_obj.keys())) before the failing subscription. Here is the program: I second Steve's comment. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: Hi! i need some help with a program in python on Raspberry pi3.
Kasper wrote: > every time i run the program i get this messeage: > > Traceback (most recent call last): > File "smartmirror.py", line 159, in get_weather > temprature2 = "%S%S" % (str(int(weather_obj['currently'] ['temperature'])), > degree_sign) > KeyError: 'currently' > Error: 'currently'. Cannot get weather. > > How do i fix that? > > Here is the program: > > weather_api_token = '16dc67b56f94f8083b1afed7e69c5dc1' # create account at > https://darksky.net/dev/ Oops, is that your personal token? You are probably not supposed to publish it and now run the risk of having it revoked. > values weather_unit = 'nb' # see https://darksky.net/dev/docs/forecast for > full list of unit parameters values You have to replace nb with one of the allowed values listed on the site. > weather_lang = 'nb' # see > https://darksky.net/dev/docs/forecast for full list of language parameters Again, you have to pick one of the values listed -- unless you want Norsk bokmål that is. -- https://mail.python.org/mailman/listinfo/python-list
Re: Hi! i need some help with a program in python on Raspberry pi3.
On Sat, 15 Apr 2017 12:27 am, Kasper wrote: > every time i run the program i get this messeage: > > Traceback (most recent call last): > File "smartmirror.py", line 159, in get_weather > temprature2 = "%S%S" % > (str(int(weather_obj['currently']['temperature'])), > degree_sign) > KeyError: 'currently' > Error: 'currently'. Cannot get weather. > > How do i fix that? We're unpaid volunteers, we're not being paid to debug your code. Don't dump over 300 lines of code in our lap and expect us to debug it. If you can't spend the time simplifying the problem and removing all the irrelevant details, how can you expect us to do it for you? If you want help, make it easy for people to help you. Cut your code down to the simplest, shortest amount of code that demonstrates the problem. If your code has nothing to do with the GUI, cut out all the GUI code. More advice here: http://sscce.org/ -- Steve “Cheer up,” they said, “things could be worse.” So I cheered up, and sure enough, things got worse. -- https://mail.python.org/mailman/listinfo/python-list