non-GUI backend

Hallo ,
I writed this program in PyCharm, but I am unable to display the image using plt.show() . The warning message is as follows.

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
  plt.show()

I have added the following code, but it still doesn’t work.

import matplotlib
matplotlib.use('TKagg')
import matplotlib.pyplot as plt

How can I resolve it?

Hi @yunpeng_huo,

I have tried to execute the below code and am able to see the image on my screen.

import matplotlib
import matplotlib.pyplot as plt
matplotlib.use('TKagg')
import numpy as np

# X axis parameter:
xaxis = np.array([2, 8])

# Y axis parameter:
yaxis = np.array([4, 9])

plt.plot(xaxis, yaxis)
plt.show()

I think you can try to uninstall and reinstall Matplotlib with the latest version in PyCharm Editor.
Still, if it doesn’t work (it may be your local environment setup problem), please use the Matplotlib forum or the Pycharm forum to resolve your issue.

Thanks.