Python3 ImportError: No module named '_tkinter'
Solution 1
I think you still need to install the tkinker package. You can do this by simply typing:
sudo apt-get install python3-tk
Solution 2
The issue as I see is that you are still calling your python3.5
binaries which might be set as default python interface. See the line in your error which tells the version of python it is referring to:
/usr/local/lib/python3.5/tkinter/
If it's a UNIX / Linux flavour you are using, you can check where are your python binaries by using
whereis python
and you will get a list of all the flavours and places it is in:
You simply call out your chosen flavor to work with, which I am guessing might be
/usr/local/bin/python3.6
and then list the available modules to check if Tkinter
is available or not, although it is highly unlikely not to as it comes bundled as a standard library.
Related videos on Youtube
TonyIT
Updated on June 04, 2022Comments
-
TonyIT almost 2 years
On my Linux Mint 18, I've tried to install Python 3.6.1 beside my 3.5.2. With these commands:
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz tar xJf Python-3.6.1.tar.xz cd Python-3.6.1 ./configure make make install
The installation was successfully but, now, every time I try to import tkinter, I have the same error:
>>> from tkinter import tk Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.5/tkinter/__init__.py", line 35, in <module> import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named '_tkinter'
I've no idea how to get rid of this issue, and how remove the 3.6.1
-
Jürgen K. over 6 yearsreally nice answer1