No module named '_tkinter'


I noticed that the service started to use ufoym/deepo docker images.
The first time I started my environment I got this error:

/usr/local/lib/python3.6/dist-packages/h5py/ FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "/usr/lib/python3.6/tkinter/", line 37, in <module>
    import _tkinter
ModuleNotFoundError: No module named '_tkinter'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/content/clouderizer/creativegan-portrait/code/", line 11, in <module>
    from utils import *
  File "/content/clouderizer/creativegan-portrait/code/", line 6, in <module>
    import matplotlib.pyplot as plt
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/", line 62, in pylab_setup
    [backend_name], 0)
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/", line 4, in <module>
    from . import tkagg  # Paint image to Tk photo blitter extension.
  File "/usr/local/lib/python3.6/dist-packages/matplotlib/backends/", line 5, in <module>
    from six.moves import tkinter as Tk
  File "/usr/local/lib/python3.6/dist-packages/", line 92, in __get__
    result = self._resolve()
  File "/usr/local/lib/python3.6/dist-packages/", line 115, in _resolve
    return _import_module(self.mod)
  File "/usr/local/lib/python3.6/dist-packages/", line 82, in _import_module
  File "/usr/lib/python3.6/tkinter/", line 39, in <module>
    raise ImportError(str(msg) + ', please install the python3-tk package')
ImportError: No module named '_tkinter', please install the python3-tk package

I solved it by following the hint given by the last line of the error, installing python3-tk. Here is the solution I used:


Yes. We released docker based setup yesterday. Thanks a lot for reporting this. We have not tested it on Ubuntu 18 yet.

I see that this error originates from your project python code. In case you code is dependent on python3-tk, you can easily add this package dependency in Clouderizer project settings -> Setup -> APT packages list. Now every time you run this project, this dependency will automatically be installed (if not already present).

Hope this helps.


Thanks to pointing that out. I remove the “Report Issue” tag to the post.
I will try to add the dependency to the project setup.