I am trying to create a Python program that uses Tkinter. I have installed Tkinter using Homebrew and did not have any errors. However, when I open Spyder and try to run it in there I get the following error:
<code>TclError: Can't find a usable init.tcl in the following directories:
/opt/homebrew/opt/tcl-tk/lib/tcl8.6 /Library/Frameworks/Python.framework/Versions/3.10/lib/tcl8.6 /Applications/Spyder.app/Contents/lib/tcl8.6 /Applications/Spyder.app/lib/tcl8.6 /Applications/Spyder.app/Contents/library /Applications/Spyder.app/library /Applications/Spyder.app/tcl8.6.12/library /Applications/tcl8.6.12/library
/opt/homebrew/opt/tcl-tk/lib/tcl8.6/init.tcl: version conflict for package "Tcl": have 8.6.12, need exactly 8.6.14
version conflict for package "Tcl": have 8.6.12, need exactly 8.6.14
while executing
"package require -exact Tcl 8.6.14"
(file "/opt/homebrew/opt/tcl-tk/lib/tcl8.6/init.tcl" line 19)
invoked from within
"source /opt/homebrew/opt/tcl-tk/lib/tcl8.6/init.tcl"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list source $tclfile]"
This probably means that Tcl wasn't installed properly.
</code>
<code>TclError: Can't find a usable init.tcl in the following directories:
/opt/homebrew/opt/tcl-tk/lib/tcl8.6 /Library/Frameworks/Python.framework/Versions/3.10/lib/tcl8.6 /Applications/Spyder.app/Contents/lib/tcl8.6 /Applications/Spyder.app/lib/tcl8.6 /Applications/Spyder.app/Contents/library /Applications/Spyder.app/library /Applications/Spyder.app/tcl8.6.12/library /Applications/tcl8.6.12/library
/opt/homebrew/opt/tcl-tk/lib/tcl8.6/init.tcl: version conflict for package "Tcl": have 8.6.12, need exactly 8.6.14
version conflict for package "Tcl": have 8.6.12, need exactly 8.6.14
while executing
"package require -exact Tcl 8.6.14"
(file "/opt/homebrew/opt/tcl-tk/lib/tcl8.6/init.tcl" line 19)
invoked from within
"source /opt/homebrew/opt/tcl-tk/lib/tcl8.6/init.tcl"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list source $tclfile]"
This probably means that Tcl wasn't installed properly.
</code>
TclError: Can't find a usable init.tcl in the following directories:
/opt/homebrew/opt/tcl-tk/lib/tcl8.6 /Library/Frameworks/Python.framework/Versions/3.10/lib/tcl8.6 /Applications/Spyder.app/Contents/lib/tcl8.6 /Applications/Spyder.app/lib/tcl8.6 /Applications/Spyder.app/Contents/library /Applications/Spyder.app/library /Applications/Spyder.app/tcl8.6.12/library /Applications/tcl8.6.12/library
/opt/homebrew/opt/tcl-tk/lib/tcl8.6/init.tcl: version conflict for package "Tcl": have 8.6.12, need exactly 8.6.14
version conflict for package "Tcl": have 8.6.12, need exactly 8.6.14
while executing
"package require -exact Tcl 8.6.14"
(file "/opt/homebrew/opt/tcl-tk/lib/tcl8.6/init.tcl" line 19)
invoked from within
"source /opt/homebrew/opt/tcl-tk/lib/tcl8.6/init.tcl"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list source $tclfile]"
This probably means that Tcl wasn't installed properly.
What is weird is if I open Spyder in terminal it runs properly without the error. I am just trying to test with a simple program before doing anything advanced. I have looked online and used A.I. to try and find this answer but nothing helps. Here is the code if it matters:
<code>import tkinter as tk
def main():
root = tk.Tk()
root.title("Hello World")
label = tk.Label(root, text="Hello World")
label.pack()
root.mainloop()
if __name__ == "__main__":
main()
</code>
<code>import tkinter as tk
def main():
root = tk.Tk()
root.title("Hello World")
label = tk.Label(root, text="Hello World")
label.pack()
root.mainloop()
if __name__ == "__main__":
main()
</code>
import tkinter as tk
def main():
root = tk.Tk()
root.title("Hello World")
label = tk.Label(root, text="Hello World")
label.pack()
root.mainloop()
if __name__ == "__main__":
main()