handle exception when import matplotlib or pylab