LoginSignup
0
1

More than 3 years have passed since last update.

【Pythonでimport matplotlib.pyplot】を使う際のエラー

Last updated at Posted at 2019-06-01

エラー

Pythonでimport matplotlib.pyplot as pltしたら下記のエラーが出た

2019-06-01 23:41:58.053 python[65992:1275150] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7fcd2f8ea010
2019-06-01 23:41:58.056 python[65992:1275150] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fcd2f8ea010'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff390b3cf9 __exceptionPreprocess + 256
        1   libobjc.A.dylib                     0x00007fff63c48a17 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff3912db06 -[NSObject(NSObject) __retain_OA] + 0
        3   CoreFoundation                      0x00007fff390560ef ___forwarding___ + 1485
        4   CoreFoundation                      0x00007fff39055a98 _CF_forwarding_prep_0 + 120
        5   libtk8.6.dylib                      0x000000010ccf731d TkpInit + 413
        6   libtk8.6.dylib                      0x000000010cc4f17e Initialize + 2622
        7   _tkinter.cpython-36m-darwin.so      0x0000000109bf3a16 _tkinter_create + 1174
        8   python                              0x00000001014ca6c8 _PyCFunction_FastCallDict + 200
        9   python                              0x00000001015a184f call_function + 143
        10  python                              0x000000010159f54a _PyEval_EvalFrameDefault + 47098
        11  python                              0x0000000101592b89 _PyEval_EvalCodeWithName + 425
        12  python                              0x00000001015a2425 _PyFunction_FastCallDict + 373
        13  python                              0x00000001014493d0 _PyObject_FastCallDict + 320
        14  python                              0x0000000101470848 method_call + 136
        15  python                              0x0000000101450a2e PyObject_Call + 62
        16  python                              0x00000001014f1a35 slot_tp_init + 117
        17  python                              0x00000001014f5f81 type_call + 241
        18  python                              0x0000000101449341 _PyObject_FastCallDict + 177
        19  python                              0x0000000101451597 _PyObject_FastCallKeywords + 327
        20  python                              0x00000001015a1948 call_function + 392
        21  python                              0x000000010159f5fa _PyEval_EvalFrameDefault + 47274
        22  python                              0x00000001015a1c0c fast_function + 188
        23  python                              0x00000001015a18ac call_function + 236
        24  python                              0x000000010159f54a _PyEval_EvalFrameDefault + 47098
        25  python                              0x0000000101592b89 _PyEval_EvalCodeWithName + 425
        26  python                              0x00000001015a2425 _PyFunction_FastCallDict + 373
        27  python                              0x00000001014493d0 _PyObject_FastCallDict + 320
        28  python                              0x0000000101470848 method_call + 136
        29  python                              0x0000000101450a2e PyObject_Call + 62
        30  python                              0x000000010159f740 _PyEval_EvalFrameDefault + 47600
        31  python                              0x0000000101592b89 _PyEval_EvalCodeWithName + 425
        32  python                              0x00000001015a1cba fast_function + 362
        33  python                              0x00000001015a18ac call_function + 236
        34  python                              0x000000010159f54a _PyEval_EvalFrameDefault + 47098
        35  python                              0x00000001015a1c0c fast_function + 188
        36  python                              0x00000001015a18ac call_function + 236
        37  python                              0x000000010159f54a _PyEval_EvalFrameDefault + 47098
        38  python                              0x0000000101592b89 _PyEval_EvalCodeWithName + 425
        39  python                              0x00000001015a1cba fast_function + 362
        40  python                              0x00000001015a18ac call_function + 236
        41  python                              0x000000010159f54a _PyEval_EvalFrameDefault + 47098
        42  python                              0x0000000101592b89 _PyEval_EvalCodeWithName + 425
        43  python                              0x00000001015a1cba fast_function + 362
        44  python                              0x00000001015a18ac call_function + 236
        45  python                              0x000000010159f54a _PyEval_EvalFrameDefault + 47098
        46  python                              0x0000000101592b89 _PyEval_EvalCodeWithName + 425
        47  python                              0x00000001015eb0dc PyRun_FileExFlags + 252
        48  python                              0x00000001015ea83e PyRun_SimpleFileExFlags + 366
        49  python                              0x0000000101611156 Py_Main + 3734
        50  python                              0x0000000101441469 main + 313
        51  libdyld.dylib                       0x00007fff654763d5 start + 1
        52  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

解決法

importする前に下記のように2行追加するとエラーが消えた。

import matplotlib
matplotlib.use('TkAgg')

参照

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1