first post; forgive any missteps.
I have just recently begun learning Python and have made it through some basic tutorials online covering the basics and am wanting to get into learning about creating GUIs in Python. To be clear, I am quite the beginner, so I may be making some silly mistakes, but for some reason, I cannot get tkinter to work in PyCharm.
Some information:
OS: MacOS Catalina 10.15.3
PyCharm: PyCharm CE (just redownloaded from site yesterday)
Have installed Python 3
In terminal, when I type "$ python --version" it returns 2.7.16, but when I type "$python3 --version" it returns 3.8.1.
I looked up some beginning tutorials on how to get started with tkinter and a simple "hello world" program. The code was as follows:
import tkinter
root = tk()
w = Label(root, text="Hello, world!")
w.pack()
root.mainloop()
However, upon running this in PyCharm with interpreter Python 3.7, I got the following error:
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/tkinter/init.py", line 36, in import _tkinter # If this fails your Python may not be configured for Tk ModuleNotFoundError: No module named '_tkinter'
When I change the interpreter to 3.8, I get this error:
root = tk() NameError: name 'tk' is not defined
I HAVE been able to produce a "Hello World" dialog box a few times by changing import tkinter to import tkinter as Tk and running it with the Python 3.8 virtual environment for some reason, but this seems like a roundabout way to do things as, in my understanding, tkinter is part of the modules included in PyCharm.
Any help would be greatly appreciated! I assume this error has something to do with the modules not being configured properly in my PyCharm or having both Python 2 and Python 3 installed? Thanks in advance for any steps I might try.
Also, is there any way I need to mark errors when posting?