Macos – ImportError: No module named tkinter. Mac OS Terminal

macosmodulepython-3.xterminaltkinter

I have created a Tkinter window in a python script. The script runs perfectly in the python IDLE and generates the GUI. However, when I run this file outside of the IDLE by clicking on it on my Desktop, the terminal responds with ImportError: No module named tkinter. Even though tkinter is installed as its a default module when python is installed. Any help is much appreciated. Im working on python 3.7

Best Answer

Make sure your default python , the one that the terminal calls has tkinter installed.

So run 'python --version' in the terminal and if that yields 3.7 then your default python is 3.7.

Now try to import tkinter using that same python version.

open the terminal and run python then run import tkinter as tk

If that does not yield an error saying that the module was not found then most probably you are running the executable with the wrong permissions.