2

I have a simple python script which use the tkinter library to create the simple form this script perfectly work on jupyer notebook and on local machine, but when I want to run in the google colab , it throws the following issue

/usr/lib/python3.6/tkinter/__init__.py in __init__(self, screenName, baseName, className, useTk, sync, use)
   2021                 baseName = baseName + ext
   2022         interactive = 0
-> 2023         self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
   2024         if useTk:
   2025             self._loadtk()

TclError: no display name and no $DISPLAY environment variable

how can I set this param for such GUI script

Mehrdad Hrsk
  • 25
  • 1
  • 4

1 Answers1

4

Colab runs your code on a cloud VM that has no attached display. There is no way for a package like tkinter to access the display of your own machine when the code is running remotely: you'll have to run your code locally instead.

jakevdp
  • 77,104
  • 11
  • 125
  • 160
  • You are correct. However, I was able to make this work on my colab. Please see my answer here, https://stackoverflow.com/questions/49478228/tclerror-no-display-name-and-no-display-environment-variable-in-google-colab – MGLondon Apr 05 '21 at 11:20