_tkinter.TclError: no display name and no $DISPLAY environment variable

Wrote a program to run on the remote server, because calling Matplotlib to draw a picture always reports an error_ Tkinter.tclerror: no display name and no $display environment variable. After a variety of data searches, we know that because the server does not have a graphical interface, some blogs recommend adding import Matplotlib matplotlib.use (‘ag ‘) at the front of the code or changing the matplotlibrc file to find the backend here, and then change it to Ag, such as backend: Ag! There are some other ways to use the tool of connecting to the server to use the graphical interface, such as putty + XMIND or xshell plus XMIND. However, the server will report errors without a graphical interface. You can add PLT. Savefig (“1. PNG”) after PLT. Show() to save the image to the server, and then take it to have a look

Similar Posts: