QXcbConnection: Could not connect to display import matplotlib; matplotlib.use('agg') 注意:要添加到所有matplotlib前面,否则不起作用