added try-except block around importing matplotlib