Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interpreter crashes trying to use tkinter library

I have tried to staring the application in VSCODE by Python3.
This is the code:

from tkinter import *

window = Tk()
window.mainloop()

only 3 lines :)), but when I'm trying to execute the file in terminal it will give me an error, which you can see below.

arash@Arash-MacBook-Pro tkinter % python3 main.py 
macOS 11 or later required !
zsh: abort ------ python3 main.py
arash@Arash-MacBook-Pro tkinter %

My Mac worked on "Big Sur" and has Python3.9.

like image 632
Arash Khosravi Avatar asked Dec 15 '20 23:12

Arash Khosravi


People also ask

Why tkinter is not working in Python?

In conclusion, if the error no module named tkinter raises, it probably means you are using python 2. Firstly, you can get around the problem by upgrading to python 3. Additionally, you can rename your import to Tkinter , which is how the module was named in python 2, just if upgrading is not an option.

Is Python tkinter deprecated?

DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it.

Is tkinter a default library?

Tkinter is the de facto way in Python to create Graphical User interfaces (GUIs) and is included in all standard Python Distributions. In fact, it's the only framework built into the Python standard library.

Is tkinter and tkinter same?

The only difference between Tkinter and tkinter is that Tkinter was initially used with Python 2 and tkinter is used for working with Python 3 or later versions.


1 Answers

This is an issue in the way brew installs Python (source). If you install Python directly via the official installer here then tkinter should work as expected.

like image 98
asherbret Avatar answered Oct 22 '22 11:10

asherbret