0

Python 2.7.11

[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

Matplotlib Version: 1.5.1

For the past two days, I've been searching the web as to why python is crashing. I have recently reinstalled python after uninstalling. Now a program I designed with Matplotlib figures running in Tkinter no longer works. I have already tried uninstalling, then reinstalling matplotlib. The error occurs in Sublime Text 2 and using the terminal. Any help would be appreciated.

This crashes:

import Tkinter as tk
import matplotlib.pyplot
print tk.Tk()

This does not crash:

import Tkinter as tk
print tk.Tk()
import matplotlib.pyplot

This does not crash:

import Tkinter as tk
import matplotlib
print tk.Tk()

Error Report:

Process: Python [59603] Path: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

Identifier: org.python.python

Version: 2.7.11 (2.7.11)

Code Type: X86-64 (Native)

Parent Process: Sublime Text 2 [38025]

Responsible: Python [59603]

User ID: 501

Date/Time: 2016-03-04 13:05:09.138 -0500

OS Version: Mac OS X 10.11 (15A278b)

Report Version: 11

Anonymous UUID: 816E9B37-C2E8-AB01-CF48-B14EDABDC5DF

Sleep/Wake UUID: D6FB01E8-81D6-42F3-BF60-D0EE4CA8C9D1

Time Awake Since Boot: 62000 seconds Time Since Wake: 12000 seconds

System Integrity Protection: disabled

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

Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY

Application Specific Information: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x1007d52d0'

abort() called terminating with uncaught exception of type NSException

Application Specific Backtrace 1: 0 CoreFoundation 0x00007fff97416bd2 __exceptionPreprocess + 178

1 libobjc.A.dylib 0x00007fff936354fa objc_exception_throw + 48

2 CoreFoundation 0x00007fff974800ed -[NSObject(NSObject) doesNotRecognizeSelector:] + 205

3 CoreFoundation 0x00007fff973873d1 forwarding + 1009

4 CoreFoundation 0x00007fff97386f58 _CF_forwarding_prep_0 + 120

5 Tk 0x0000000101c66958 TkpInit + 476

6 Tk 0x0000000101be1a7e Tk_Init + 1799

7 _tkinter.so 0x0000000101abe9fd Tcl_AppInit + 77

8 _tkinter.so 0x0000000101abc1e5 Tkinter_Create + 997

9 Python 0x00000001000c710c PyEval_EvalFrameEx + 40108

10 Python 0x00000001000c7ff3 PyEval_EvalCodeEx + 2131

11 Python 0x000000010003e1e0 function_call + 176

12 Python 0x000000010000c442 PyObject_Call + 98

13 Python 0x000000010001ec2d instancemethod_call + 365

14 Python 0x000000010000c442 PyObject_Call + 98

15 Python 0x00000001000bc1a7 PyEval_CallObjectWithKeywords + 87

16 Python 0x0000000100021f1e PyInstance_New + 126

17 Python 0x000000010000c442 PyObject_Call + 98

18 Python 0x00000001000bfc73 PyEval_EvalFrameEx + 10259

19 Python 0x00000001000c7ff3 PyEval_EvalCodeEx + 2131

20 Python 0x00000001000c8116 PyEval_EvalCode + 54

21 Python 0x00000001000ed0fe PyRun_FileExFlags + 174

22 Python 0x00000001000ed39a PyRun_SimpleFileExFlags + 458

23 Python 0x000000010010457d Py_Main + 3101

24 Python 0x0000000100000f14 Python + 3860

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

0 libsystem_kernel.dylib 0x00007fff9722a0ae __pthread_kill + 10

1 libsystem_pthread.dylib 0x00007fff93baf500 pthread_kill + 90

2 libsystem_c.dylib 0x00007fff8706437b abort + 129

3 libc++abi.dylib 0x00007fff935d8f81 abort_message + 257

4 libc++abi.dylib 0x00007fff935fea47 default_terminate_handler() + 267

5 libobjc.A.dylib 0x00007fff9363715e _objc_terminate() + 103

6 libc++abi.dylib 0x00007fff935fc19e std::__terminate(void (*)()) + 8

7 libc++abi.dylib 0x00007fff935fbc12 __cxa_throw + 121

8 libobjc.A.dylib 0x00007fff93635608 objc_exception_throw + 318

9 com.apple.CoreFoundation 0x00007fff974800ed -[NSObject(NSObject) doesNotRecognizeSelector:] + 205

10 com.apple.CoreFoundation 0x00007fff973873d1 forwarding + 1009

11 com.apple.CoreFoundation 0x00007fff97386f58 _CF_forwarding_prep_0 + 120

12 Tk 0x0000000101c66958 TkpInit + 476

13 Tk 0x0000000101be1a7e 0x101bb3000 + 191102

14 _tkinter.so 0x0000000101abe9fd Tcl_AppInit + 77

15 _tkinter.so 0x0000000101abc1e5 Tkinter_Create + 997

16 org.python.python 0x00000001000c710c PyEval_EvalFrameEx + 40108

17 org.python.python 0x00000001000c7ff3 PyEval_EvalCodeEx + 2131

18 org.python.python 0x000000010003e1e0 function_call + 176

19 org.python.python 0x000000010000c442 PyObject_Call + 98

20 org.python.python 0x000000010001ec2d instancemethod_call + 365

21 org.python.python 0x000000010000c442 PyObject_Call + 98

22 org.python.python 0x00000001000bc1a7 PyEval_CallObjectWithKeywords + 87

23 org.python.python 0x0000000100021f1e PyInstance_New + 126

24 org.python.python 0x000000010000c442 PyObject_Call + 98

25 org.python.python 0x00000001000bfc73 PyEval_EvalFrameEx + 10259

26 org.python.python 0x00000001000c7ff3 PyEval_EvalCodeEx + 2131

27 org.python.python 0x00000001000c8116 PyEval_EvalCode + 54

28 org.python.python 0x00000001000ed0fe PyRun_FileExFlags + 174

29 org.python.python 0x00000001000ed39a PyRun_SimpleFileExFlags + 458

30 org.python.python 0x000000010010457d Py_Main + 3101

31 org.python.python 0x0000000100000f14 0x100000000 + 3860

Thread 1:: Dispatch queue: com.apple.libdispatch-manager

0 libsystem_kernel.dylib 0x00007fff9722b0a2 kevent_qos + 10

1 libdispatch.dylib 0x00007fff8bd2c1ad _dispatch_mgr_invoke + 216

2 libdispatch.dylib 0x00007fff8bd2be15 _dispatch_mgr_thread + 52

Thread 2:

0 libsystem_kernel.dylib 0x00007fff9722a78a __workq_kernreturn + 10

1 libsystem_pthread.dylib 0x00007fff93bac58c _pthread_wqthread + 1283

2 libsystem_pthread.dylib 0x00007fff93baa375 start_wqthread + 13

Thread 3:

0 libsystem_kernel.dylib 0x00007fff9722a78a __workq_kernreturn + 10

1 libsystem_pthread.dylib 0x00007fff93bac58c _pthread_wqthread + 1283

2 libsystem_pthread.dylib 0x00007fff93baa375 start_wqthread + 13

Thread 4:

0 libsystem_kernel.dylib 0x00007fff9722a78a __workq_kernreturn + 10

1 libsystem_pthread.dylib 0x00007fff93bac58c _pthread_wqthread + 1283

2 libsystem_pthread.dylib 0x00007fff93baa375 start_wqthread + 13

Thread 5:

0 libsystem_kernel.dylib 0x00007fff9722a78a __workq_kernreturn + 10

1 libsystem_pthread.dylib 0x00007fff93bac58c _pthread_wqthread + 1283

2 libsystem_pthread.dylib 0x00007fff93baa375 start_wqthread + 13

Thread 6:

0 libsystem_kernel.dylib 0x00007fff9722a78a __workq_kernreturn + 10

1 libsystem_pthread.dylib 0x00007fff93bac58c _pthread_wqthread + 1283

2 libsystem_pthread.dylib 0x00007fff93baa375 start_wqthread + 13

...

Model: MacBookAir6,2, BootROM MBA61.0099.B19, 2 processors, Intel Core i5, 1.3 GHz, 4 GB, SMC 2.13f15

Graphics: Intel HD Graphics 5000, Intel HD Graphics 5000, Built-In

Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1600 MHz, 0x80AD, 0x483943434E4E4E384A544D4C41522D4E544D

Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1600 MHz, 0x80AD, 0x483943434E4E4E384A544D4C41522D4E544D

AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x117), Broadcom BCM43xx 1.0 (7.21.94.23.1a20)

Bluetooth: Version 4.4.0f4 16320, 3 services, 27 devices, 1 incoming serial ports

Network Service: Wi-Fi, AirPort, en0

Serial ATA Device: APPLE SSD SD0128F, 121.33 GB

USB Device: USB 3.0 Bus

USB Device: BRCM20702 Hub

USB Device: Bluetooth USB Host Controller

USB Device: iPhone

Thunderbolt Bus: MacBook Air, Apple Inc., 23.6

2 Answers2

0

I found that the first (and only) answer from this thread solved the issue for me:

Installation Issue with matplotlib Python

Details: I was getting this exception with the Anaconda Python 2.7 distribution. I read a suggestion somewhere that matplotlib needs to be compiled from source, so I switched to a homebrew install with the --build-from-source flag. This produced a useful error message, which I then used to find the thread above:

RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ
Community
  • 1
  • 1
0

On a mac, you can use TkAgg or Qt4Agg as the backend

import matplotlib matplotlib.use("TkAgg")

Alternatively if you have QT4 installed, you can use that as the backend. The setup is a little more complicated. You need PyQT4 or PyQT5. You can download it from source here and build it: https://www.riverbankcomputing.com/software/pyqt/download

Remember if you use PyQT, you also need to download and build SIP: https://www.riverbankcomputing.com/software/sip/download

Run python configure.py and it will build the Makefile, then make and make install.

After you install QT4 and PyQT4, you can set the backend to Qt4Agg. I'm using QT4 and it works great!

Rohit
  • 428
  • 4
  • 17