2

I've encountered a problem while attempting to create a Tkinter window using root = tk.Tk() . Every time I get to that point, the program crashes, and "Python quit unexpectedly" message is displayed.

I get no tracebacks at all, so I assume that is the ActiveTcl bug. However, I have the new distribution from ActiveTcl Website installed, which is supposed to take care of the problem (obviously, it doesn't).

Interestingly enough, it only crashes when it is executed in Python 2.7. It works fine in Python 3.6. However, I need to use 2.7.

My MacOS version is 10.12.5.

Any ideas / suggestions about fixing the issue are welcome.

P.S. I have read a good dozen of similar posts before posting this, and not any of the proposed solutions worked for me. Please consider this before marking this post as a duplicate.

martineau
  • 119,623
  • 25
  • 170
  • 301
altskop
  • 311
  • 2
  • 12
  • What happens when you open an interactive prompt, you import tkinter, and then create the root window? It seems like you're saying you are simply returned to the bash prompt without any message whatsoever. Is that correct? – Bryan Oakley Aug 02 '17 at 18:46
  • I just tried this out and found out that I can't import any of my modules when I'm in the interactive prompt. – altskop Aug 02 '17 at 18:52
  • 2
    "Can't" is rather vague. Why can't you? What does the error say? It sounds like python is simply looking in the wrong place for packages. – Bryan Oakley Aug 02 '17 at 19:00
  • Sorry, I get "module isn't found" error on any of the modules I try to import. This is exactly what it appears to me as well. – altskop Aug 02 '17 at 19:02
  • 1
    So, examine your PYTHONPATH variable (or `sys.path` if you're able to import the `sys` module). – Bryan Oakley Aug 02 '17 at 19:08
  • please post your code for us, in some cases, the code makes this problem. – nima Aug 02 '17 at 19:47

3 Answers3

1

I don't know what is meant by "new distribution" for ActiveTcl is but if you're using 8.6, it needs to be downgraded to 8.5.

Also, if you run IDLE which uses Tkinter, do you see any messages warning of "instability"? If you see that then, it means you need to downgrade Tcl to 8.5.

ssleung
  • 54
  • 2
0

Are you running Python 3 through Anaconda? Tkinter was acting all sorts of funky on me and then I uninstalled Anaconda and now it works fine.

Interestingly enough, I am running a PyCharm Professional / Anaconda combo on a Windows 10 VM on my Mac, and I have issues with Tkinter on it as well. I have absolutely no issues however on my Linux Mint box.

To reiterate, I was able to remove the issue by completely removing Anaconda. (How to uninstall Anaconda completely from macOS)

trozzel
  • 479
  • 5
  • 12
-1

Tkinter needs to be imported like this in order to work with both python 2 and 3:

try:
    import tkinter
except ImportError:    # python 2
    import Tkinter as tkinter