Plot not showing in Ubuntu terminal

I am using [import matplotlib.pyplot as plt] in a code in ubuntu terminal and thats showing segmentation error but when i used [matplotlib.use(‘TkAgg’)] graph is showing so what to do about that?