“1995 is calling… it wants its user interfaces back!”
Sorry, I couldn’t let this go. π TKinter is actually a great Python library and you can use it to make modern user interfaces too. This tutorial shows you how to fix the No Module Named 'tkinter'
error.
Quick Fix: π
Python raises the ImportError: No module named 'tkinter'
when it cannot find the library tkinter
. Tkinter is part of Python’s standard library, so for modern Python installations, you can just import tkinter
without needing to install it first. But in some environments, you may need to install it using pip install python3-tkinter
or variants thereof.

Alternatively, you may have different Python versions on your computer, and tkinter
is not installed for the particular version you’re using.
Here are some variants you may want to try to fix the error and install tkinter
in your environment:
π‘ If you have only one version of Python installed:pip install python3-tkinter
π‘ If you have Python 3 (and, possibly, other versions) installed:pip3 install
π‘ If you don't have PIP or it doesn't work
python3-tkinter
python -m pip install
π‘ If you have Linux and you need to fix permissions (any one):python3 -m pip install
python3-tkinter
python3-tkinter
sudo pip3 install
π‘ If you have Linux or Ubuntu with aptpip3 install
python3-tkinter
--user
python3-tkinter
sudo apt-get install
π‘ If you're using macOS and you want to install Python 3.9 Tkinter (any):
python3-tk
brew install python-tk@3.9 brew install python-tk
π‘ If you have Fedorasudo dnf install python3-tkinter
π‘ If you have Windows and you have set up thepy
aliaspy -m pip install
π‘ If you have Anaconda
python3-tkinter
conda install -c anaconda
π‘ If you have Jupyter Notebook
python3-tkinter
!pip install
python3-tkinter
!pip3 install
python3-tkinter
π¬ Summary: You see that most solutions concern a combination of the installation tool (e.g., pip
or brew
or conda
) and any of the library name variations python3-tkinter
, python-tkinter
, python3-tk
, or python-tk
.
But as I mentioned before, likely, you don’t need to install it because it’s already part of Python’s standard library, so a simple import
statement should be sufficient if your Python is correctly installed!
π Recommended Tutorial: How to Install Python?
Speaking of the import
statement—older versions of Tkinter came with some confusion about the capitalization of its name.
In Python 3, the module was renamed from Tkinter
(Python 2) to tkinter
(Python 3), as stated in the docs:
π Note: Tkinter has been renamed to tkinter in Python 3. The 2to3
tool will automatically adapt imports when converting your sources to Python 3.
The following code snippet was proposed to overcome these issues for different Python versions (2 vs 3):
Instead of:
import tkinter
You can run:
import sys if sys.version_info[0] == 3: import tkinter as tk else: import Tkinter as tk
To import Tkinter independently of your concrete (local) Python version.
By the way, this is how the error may look when you try to import the tkinter library into your (virtual) environment and Python raises the following ImportError: No module named tkinter
:
>>> import tkinter Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> import tkinter ModuleNotFoundError: No module named 'tkinter'
Windows Solution Idea: Fix the Path
The error might persist even after you have installed the tkinter
library. This likely happens because pip
is installed but doesn’t reside in the path you can use. Although pip
may be installed on your system the script is unable to locate it. Therefore, it is unable to install the library using pip
in the correct path.
To fix the problem with the path in Windows follow the steps given next.
Step 1: Open the folder where you installed Python by opening the command prompt and typing where python

Step 2: Once you have opened the Python
folder, browse and open the Scripts
folder and copy its location. Also verify that the folder contains the pip
file.

Step 3: Now open the Scripts
directory in the command prompt using the cd
command and the location that you copied previously.

Step 4: Now install the library using pip install tkinter
command. Here’s an analogous example:

After having followed the above steps, execute our script once again. And you should get the desired output.
Other Solution Ideas
- The
ModuleNotFoundError
may appear due to relative imports. You can learn everything about relative imports and how to create your own module in this article. - You may have mixed up Python and pip versions on your machine. Use Python 3 and you should be able to import Tkinter without error.
- You can also check out this article to learn more about possible problems that may lead to an error when importing a library.
Understanding the “import” Statement
import tkinter
In Python, the import
statement serves two main purposes:
- Search the module by its name, load it, and initialize it.
- Define a name in the local namespace within the scope of the
import
statement. This local name is then used to reference the accessed module throughout the code.
What’s the Difference Between ImportError and ModuleNotFoundError?
What’s the difference between ImportError
and ModuleNotFoundError
?
Python defines an error hierarchy, so some error classes inherit from other error classes. In our case, the ModuleNotFoundError
is a subclass of the ImportError
class.
You can see this in this screenshot from the docs:

You can also check this relationship using the issubclass()
built-in function:
>>> issubclass(ModuleNotFoundError, ImportError) True
Specifically, Python raises the ModuleNotFoundError
if the module (e.g., tkinter
) cannot be found. If it can be found, there may be a problem loading the module or some specific files within the module. In those cases, Python would raise an ImportError
.
If an import statement cannot import a module, it raises an ImportError
. This may occur because of a faulty installation or an invalid path. In Python 3.6 or newer, this will usually raise a ModuleNotFoundError
.
Related Videos
The following video shows you how to resolve the ImportError
:
The following video shows you how to import a function from another folder—doing it the wrong way often results in the ModuleNotFoundError
:

While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.