python3 tkinter ubuntu trusty does not work under virtual environment python3 tkinter ubuntu trusty does not work under virtual environment python-3.x python-3.x

python3 tkinter ubuntu trusty does not work under virtual environment


So from the error message, python3-tk package is missed.

raise ImportError(str(msg) + ', please install the python3-tk package') ImportError: No module named '_tkinter', please install the python3-tk package

Did you try to install it? for example, in ubuntu

sudo apt-get install python3-tk


I had the same problem. The answer provided by user BMW did not work for me. There is no need to recreate the virtualenv directory, like user1256124 suggests, although that is a perfectly workable solution as well.

Just use the bindings specific to the version of python that you need. For python3.6, this command is:

sudo apt-get install python3.6-tk

This allows an already set up virtualenv to find the right libraries.


I figured it out.What was happening is that once python3 virtualenv was created there was no more inheriting to be done from the python3 apt-get installation.Once I recreated the image from the updated Dockerfile in which it was specified to apt-get install python3-tk BEFORE creating the python3 virtualenv, then everything worked.Not sure why this is the case though.