This error:
TclError: no display name and no $DISPLAY environment variable
arose when I tried to run a Python 3.6 program inside Google Colab (collaborative Jupyter notebooks). I am running Colab in Chrome on a Windows 10 machine. I've seen this error reported in other threads on Stack Overflow but not in the context of Colab, and previously posted solutions either don't apply or don't seem to work.
My code begins like this:
from matplotlib.pyplot import *
from matplotlib.widgets import *
from math import *
from random import *
from numpy import *
from tkinter import *
Note that to get the import of tkinter to work, I had to issue the following instruction in a different Colab cell:
!apt-get install python3-tk