简体   繁体   中英

Python quit unexpectedly

Can anybody help with this? Whenever I try to launch tkinter, i get this report:

Process: Python [1106] Path:
/Library/Frameworks/Python.framework/Versions/3.5/Resources/Python.app/Contents/MacOS/Python Identifier: org.python.python Version: 3.5.1 (3.5.1) Code Type: X86-64 (Native) Parent Process:
Python [1036] Responsible: Python [1036] User ID:
501

Date/Time: 2016-04-28 00:14:59.804 -0500 OS Version:
Mac OS X 10.10.5 (14F1713) Report Version: 11 Anonymous UUID:
8A5EA9E5-B94F-6C3F-2F7E-EC33C5FA8E26

Time Awake Since Boot: 4900 seconds

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes:
KERN_INVALID_ADDRESS at 0x00007fff5afffff8

VM Regions Near 0x7fff5afffff8: mapped file 000000010a37f000-000000010a409000 [ 552K] rw-/rwx SM=COW /System/Library/Fonts/Monaco.dfont --> __UNIXSTACK 00007fff5b000000-00007fff5c000000 [ 16.0M] rw-/rwx SM=COW /Library/Frameworks/Python.framework/Versions/3.5/Resources/Python.app/Contents/MacOS/Python

If you are using Homebrew , you can reinstall a corrupted Python environment like this:

brew uninstall --ignore-dependencies --force python python@2
unset PYTHONPATH
brew install python python@2

I had another "quit unexpectedly" issue and this resolved it for me.

Python quit unexpectedly when running the code below on my Mac (OS X Yosemite):

root.config(menu_Bar = file_Menu)


# Tkinter GUI Menu

from tkinter import *

### Functions ###

# Do Nothing
def do_Nothing():
    print('I just did... nothing')



### Create tkinter window ###

# Create Window
root = Tk() 



#### Creating the Menu(s) ###

# Create the Menu Bar
menu_Bar = Menu(master = root)

# Create File Menu
file_Menu = Menu(master = menu_Bar)



### Displaying the Menu(s) ###

# Display Menu Bar
root.config(menu = menu_Bar)

# Display File Menu
menu_Bar.add_cascade(label = 'File', menu = file_Menu)




### File Menu Properties ####

# New
file_Menu.add_command(label = 'New', command = do_Nothing)

# Open
file_Menu.add_command(label = 'Open', command = do_Nothing)

# Exit
file_Menu.add_command(label = 'Exit', command = root.quit) 




### Display tkinter window ###
root.mainloop()


# Display Menu Bar
root.config(menu = menu_Bar)

The issue that made Python quit unexpectedly was that instead of

# Display Menu Bar
root.config(menu = menu_Bar)

I had originally wrote something like:

# Display Menu Bar
root.config(myMenu = menu_Bar)

In addition to that, I had to update the Tlc from version Apple 8.5.9 to ActiveTcl 8.5.18.0 . The website for this is here: https://www.python.org/download/mac/tcltk/#activetcl-8-5-18-0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM