RuntimeError: Invalid DISPLAY variable

远程服务器出图报错

这个错是因为远程的服务器没有图形化界面。所以我们需要在代码中加入:

import matplotlib.pyplot as plt
plt.switch_backend('agg')
即,使用不需要GUI的Backend,这样就可以了

猜你喜欢

转载自blog.csdn.net/Mr_Brooks/article/details/80230857