Whenever I use the matplotlib.pyplot.show function in a Python program, it results in output such as below while the program runs correctly otherwise:
1 HIToolbox 0x00007ff81116c0c2 _ZN15MenuBarInstance22RemoveAutoShowObserverEv + 30
2 HIToolbox 0x00007ff8111837e3 SetMenuBarObscured + 115
3 HIToolbox 0x00007ff81118a29e _ZN13HIApplication11FrontUILostEv + 34
4 HIToolbox 0x00007ff811183622 _ZN13HIApplication15HandleActivatedEP14OpaqueEventRefhP15OpaqueWindowPtrh + 508
5 HIToolbox 0x00007ff81117d950 _ZN13HIApplication13EventObserverEjP14OpaqueEventRefPv + 182
6 HIToolbox 0x00007ff811145bd2 _NotifyEventLoopObservers + 153
7 HIToolbox 0x00007ff81117d3e6 AcquireEventFromQueue + 494
8 HIToolbox 0x00007ff81116c5a4 ReceiveNextEventCommon + 725
9 HIToolbox 0x00007ff81116c2b3 _BlockUntilNextEventMatchingListInModeWithFilter + 70
10 AppKit 0x00007ff80a973f33 _DPSNextEvent + 909
11 AppKit 0x00007ff80a972db4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1219
12 AppKit 0x00007ff80a9653f7 -[NSApplication run] + 586
13 _macosx.cpython-310-darwin.so 0x0000000110407e22 show + 162
14 Python 0x0000000100bb7595 cfunction_vectorcall_NOARGS + 101
15 Python 0x0000000100c9101f call_function + 175
16 Python 0x0000000100c8a2c4 _PyEval_EvalFrameDefault + 34676
17 Python 0x0000000100c801df _PyEval_Vector + 383
18 Python 0x0000000100c9101f call_function + 175
19 Python 0x0000000100c8a2c4 _PyEval_EvalFrameDefault + 34676
20 Python 0x0000000100c801df _PyEval_Vector + 383
21 Python 0x0000000100b53f61 method_vectorcall + 481
22 Python 0x0000000100c8a4f2 _PyEval_EvalFrameDefault + 35234
23 Python 0x0000000100c801df _PyEval_Vector + 383
24 Python 0x0000000100c9101f call_function + 175
25 Python 0x0000000100c8a2c4 _PyEval_EvalFrameDefault + 34676
26 Python 0x0000000100c801df _PyEval_Vector + 383
27 Python 0x0000000100cf536d pyrun_file + 333
28 Python 0x0000000100cf4b2d _PyRun_SimpleFileObject + 365
29 Python 0x0000000100cf417f _PyRun_AnyFileObject + 143
30 Python 0x0000000100d20047 pymain_run_file_obj + 199
31 Python 0x0000000100d1f815 pymain_run_file + 85
32 Python 0x0000000100d1ef9e pymain_run_python + 334
33 Python 0x0000000100d1ee07 Py_RunMain + 23
34 Python 0x0000000100d201e2 pymain_main + 50
35 Python 0x0000000100d2048a Py_BytesMain + 42
36 dyld 0x00007ff80741b310 start + 2432
This happens even when the program is as simple as the following:
import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [1, 2, 3]
plt.plot(x, y)
plt.show()
Other than the unwanted output, this or any other program with the matplotlib.pyplot.show function appears to run correctly, including the graph displays triggered by the show function. If I remove plt.show() from the code above or any of the other programs, the unwanted output does not come out but then the graph is also not displayed.
I have Matplotlib 3.5.2 and Python v3.10.4 installed along with macOS Venture v13.1 on my Mac. I get this unwanted output when I use macOS’s command line interface to run the above program or any of the others with the matplotlib.pyplot.show function (assume the program’s name is test.py
):
python3 test.py
I get the unwanted output when I also use Visual Studio Code v1.74.2 to run the program but not if I use IDLE, Python’s Integrated Development and Learning Environment, or run the code in it from within a Jupyter notebook.
I can remove the show function from my Python programs to avoid the unwanted output but then the charts will not appear and I would prefer using the show function rather than a makeshift solution.
My questions are:
- Why do I get this output even though there is nothing in the above code that would normally trigger it?
- How is this output helpful, if any, and, if so, how can it be used if needed?
- How can I prevent it from coming out after using the show function?