The following code runs without errors.
import kivy
def main():
try:
kivy.require('1.9.2')
except Exception as e:
import traceback
traceback.print_exc()
#import kivy.base
if __name__ in ('__main__'):
main()
However, if I un-comment line 8, it prints:
Traceback (most recent call last):
File "main.py", line 4, in main
kivy.require('1.9.2')
UnboundLocalError: local variable 'kivy' referenced before assignment
I have two questions:
- Why is
kivy
on line 4 recognized as a variable instead of a module? - How does line 8 affect whether line 4 raises an exception?