-1

i am getting this error TclError: no display name and no $DISPLAY environment variable
should i include matplotlib or something else and i am working on colab.


# Import tkinter as tk 
import tkinter as tk 
  
# creating a new tkinter window 
master = tk.Tk()  
  
# assigning a title 
master.title("MARKSHEET") 
  
# specifying geomtery for window size  
master.geometry("700x250")  
  
and the rest of the code  
     
master.mainloop() 

why this error and what can be done??

1 Answers1

0

You didn't elaborate your question enough. It would be nice if you share the complete traceback, what OS you use, what python version you use, what modules you use etc... But without any info several reasons are possible.

If you use matplotlib module. matplotlib chooses Xwindows backend by default. You need to set matplotlib to NOT use the Xwindows backend.

import matplotlib
matplotlib.use('Agg')

If you run your code via SSH. You should set the -X parameter.

ssh -X user@hostname

You should try to export the DISPLAY environment variable:

export DISPLAY=:0
milanbalazs
  • 4,811
  • 4
  • 23
  • 45