Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib abort trap on MacOS X #10554

Closed
astrofrog opened this issue Jan 28, 2019 · 7 comments
Closed

Matplotlib abort trap on MacOS X #10554

astrofrog opened this issue Jan 28, 2019 · 7 comments

Comments

@astrofrog
Copy link

Actual Behavior

Matplotlib crashes when I try and create a figure:

2019-01-28 12:35:02.160 python[26959:214762] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7f8646d90390
2019-01-28 12:35:02.164 python[26959:214762] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7f8646d90390'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff469f6ecd __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff72aae720 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff46a74275 -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00007fff46998b40 ___forwarding___ + 1486
	4   CoreFoundation                      0x00007fff469984e8 _CF_forwarding_prep_0 + 120
	5   libtk8.6.dylib                      0x000000011f51531d TkpInit + 413
	6   libtk8.6.dylib                      0x000000011f46d17e Initialize + 2622
	7   _tkinter.cpython-36m-darwin.so      0x000000011c7f4a16 _tkinter_create + 1174
	8   python                              0x000000010c982068 _PyCFunction_FastCallDict + 200
	9   python                              0x000000010ca5761f call_function + 143
	10  python                              0x000000010ca55175 _PyEval_EvalFrameDefault + 46837
	11  python                              0x000000010ca488c9 _PyEval_EvalCodeWithName + 425
	12  python                              0x000000010ca582cc _PyFunction_FastCallDict + 364
	13  python                              0x000000010c900f80 _PyObject_FastCallDict + 320
	14  python                              0x000000010c9285f8 method_call + 136
	15  python                              0x000000010c9085ce PyObject_Call + 62
	16  python                              0x000000010c9a95b5 slot_tp_init + 117
	17  python                              0x000000010c9adaf1 type_call + 241
	18  python                              0x000000010c900ef1 _PyObject_FastCallDict + 177
	19  python                              0x000000010c909137 _PyObject_FastCallKeywords + 327
	20  python                              0x000000010ca57718 call_function + 392
	21  python                              0x000000010ca55225 _PyEval_EvalFrameDefault + 47013
	22  python                              0x000000010ca579dc fast_function + 188
	23  python                              0x000000010ca5767c call_function + 236
	24  python                              0x000000010ca55175 _PyEval_EvalFrameDefault + 46837
	25  python                              0x000000010ca488c9 _PyEval_EvalCodeWithName + 425
	26  python                              0x000000010ca582cc _PyFunction_FastCallDict + 364
	27  python                              0x000000010c900f80 _PyObject_FastCallDict + 320
	28  python                              0x000000010c9285f8 method_call + 136
	29  python                              0x000000010c9085ce PyObject_Call + 62
	30  python                              0x000000010ca55376 _PyEval_EvalFrameDefault + 47350
	31  python                              0x000000010ca488c9 _PyEval_EvalCodeWithName + 425
	32  python                              0x000000010ca57a8a fast_function + 362
	33  python                              0x000000010ca5767c call_function + 236
	34  python                              0x000000010ca55175 _PyEval_EvalFrameDefault + 46837
	35  python                              0x000000010ca488c9 _PyEval_EvalCodeWithName + 425
	36  python                              0x000000010caa155c PyRun_FileExFlags + 252
	37  python                              0x000000010caa0a34 PyRun_SimpleFileExFlags + 372
	38  python                              0x000000010cac77c6 Py_Main + 3734
	39  python                              0x000000010c8f8f59 main + 313
	40  libdyld.dylib                       0x00007fff73b7ced9 start + 1
	41  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

Expected Behavior

Matplotlib should not crash!

Steps to Reproduce

conda create -n debug-mpl python=3.6 matplotlib

then (in Python):

import matplotlib.pyplot as plt
fig = plt.figure()  # causes crash
Anaconda or Miniconda version:

Miniconda latest

Operating System:

MacOS X 10.14.2

conda info

     active environment : debug-mpl
    active env location : /Users/tom/miniconda3/envs/debug-mpl
            shell level : 1
       user config file : /Users/tom/.condarc
 populated config files : /Users/tom/.condarc
          conda version : 4.5.12
    conda-build version : 3.17.5
         python version : 3.7.0.final.0
       base environment : /Users/tom/miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/osx-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/osx-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/osx-64
                          https://repo.anaconda.com/pkgs/pro/noarch
          package cache : /Users/tom/miniconda3/pkgs
                          /Users/tom/.conda/pkgs
       envs directories : /Users/tom/miniconda3/envs
                          /Users/tom/.conda/envs
               platform : osx-64
             user-agent : conda/4.5.12 requests/2.19.1 CPython/3.7.0 Darwin/18.2.0 OSX/10.14.2
                UID:GID : 504:20
             netrc file : /Users/tom/.netrc
           offline mode : False
conda list --show-channel-urls
# packages in environment at /Users/tom/miniconda3/envs/debug-mpl:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl    defaults
ca-certificates           2018.12.5                     0    defaults
certifi                   2018.11.29               py36_0    defaults
cycler                    0.10.0           py36hfc81398_0    defaults
freetype                  2.9.1                hb4e5f40_0    defaults
intel-openmp              2019.1                      144    defaults
kiwisolver                1.0.1            py36h0a44026_0    defaults
libcxx                    4.0.1                hcfea43d_1    defaults
libcxxabi                 4.0.1                hcfea43d_1    defaults
libedit                   3.1.20181209         hb402a30_0    defaults
libffi                    3.2.1                h475c297_4    defaults
libgfortran               3.0.1                h93005f0_2    defaults
libpng                    1.6.36               ha441bb4_0    defaults
matplotlib                3.0.2            py36h54f8f79_0    defaults
mkl                       2019.1                      144    defaults
mkl_fft                   1.0.10           py36h5e564d8_0    defaults
mkl_random                1.0.2            py36h27c97d8_0    defaults
ncurses                   6.1                  h0a44026_1    defaults
numpy                     1.15.4           py36hacdab7b_0    defaults
numpy-base                1.15.4           py36h6575580_0    defaults
openssl                   1.1.1a               h1de35cc_0    defaults
pip                       18.1                     py36_0    defaults
pyparsing                 2.3.1                    py36_0    defaults
python                    3.6.8                haf84260_0    defaults
python-dateutil           2.7.5                    py36_0    defaults
pytz                      2018.9                   py36_0    defaults
readline                  7.0                  h1de35cc_5    defaults
setuptools                40.6.3                   py36_0    defaults
six                       1.12.0                   py36_0    defaults
sqlite                    3.26.0               ha441bb4_0    defaults
tk                        8.6.8                ha441bb4_0    defaults
tornado                   5.1.1            py36h1de35cc_0    defaults
wheel                     0.32.3                   py36_0    defaults
xz                        5.2.4                h1de35cc_4    defaults
zlib                      1.2.11               h1de35cc_3    defaults
@astrofrog
Copy link
Author

Also just to add, I don't have a Matplotlib rc file, so this is defaulting to the Tk backend.

@jjhelmus
Copy link
Contributor

jjhelmus commented Jan 29, 2019

@astrofrog I've been looking into this and was not able to find the root cause of the issue. I can replace the issue as described on a test machine. I noticed that setting the TkAgg backend prior to importing pyplot allows the script to run without issue:

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
fig = plt.figure()

Running the original script using MPLBACKEND="TKAGG" python script.py or pythonw scripy.py after installing the python.app package also work.

Perhaps one of these work arounds can get you unstuck until a root cause is identified.

@astrofrog
Copy link
Author

@jjhelmus - thanks for the workaround - I'm indeed able to avoid the issue by setting the backend

@jjhelmus
Copy link
Contributor

This issue due to some interactions between the macosx and tkagg backends in matplotlib, see matplotlib/matplotlib#13096. It will need to be fixed upstream. Until then the work around are the best option.

@tovrstra
Copy link

@jjhelmus This problem got fixed in Matplotlib 3.1.0, but the default conda channels still have 3.0.3, i.e. with the bug.

Would it be possible to upgrade to 3.1.0? It is rather awkward that matplotlib is broken in its default configuration on macos. Thanks!

@jjhelmus
Copy link
Contributor

matplotlib 3.1.0 is now available in defaults

@tovrstra
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants