The pyplot of python in Mac calls show () Times error, how to solve it?

The code of the

Python file is as follows:

import matplotlib.pyplot as plt

fig = plt.figure()
plt.show()

after execution, you can run the display window:

but the problem is that once the touch mouse (MagicMouse) scrolls in the Figure window, it will report an error:
Traceback (most recent call last):
  File "/Users/***/PycharmProjects/LNN/venv/pltTest.py", line 4, in <module>
    plt.show()
  File "/Users/***/PycharmProjects/LNN/venv/lib/python3.6/site-packages/matplotlib/pyplot.py", line 253, in show
    return _show(*args, **kw)
  File "/Users/***/PycharmProjects/LNN/venv/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 208, in show
    cls.mainloop()
  File "/Users/***/PycharmProjects/LNN/venv/lib/python3.6/site-packages/matplotlib/backends/_backend_tk.py", line 1073, in mainloop
    Tk.mainloop()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 557, in mainloop
    _default_root.tk.mainloop(n)
UnicodeDecodeError: "utf-8" codec can"t decode byte 0xff in position 0: invalid start byte

doesn"t pyplot support gestures that touch the mouse? Although the operation can be avoided, it won"t hurt to report this mistake, but I still want to know the reason and the solution. I hope a great god can answer it.

Mar.17,2021

refer to the answer in [ https://github.com/dmsenter89.], the reason and solution is [It looks like this is a known problem for instances of Python installed with Homebrew.] Using an installation directly from python.org or Anaconda should resolve the issue.]
but it is troublesome to install again, so I didn't try whether it is possible or not. I used another code solution, referring to [ https://github.com/matplotlib.]

.
while True:
    try:
        plt.show()
    except UnicodeDecodeError:
        continue
    break

this can solve the problem. I hope it can help

.
Menu