[Python] Pycharm errors when showing plot

Discussão em 'Python' iniciado por Stack, Agosto 24, 2025.

  1. Stack

    Stack Membro Participativo

    I am using the latest version of Pycharm and using Python interpreter version 3.10. I have matplotlib, numpy and six packages installed in the settings-> python interpreter section. I wrote the following code

    from typing import Tuple, Any
    import matplotlib.pyplot as plt
    import numpy as np
    X = np.array([1, 3, 5, 7, 9])
    Y = np.array([12, 15, 18, 21, 30])

    plt.plot(X,Y)
    plt.show()


    Now when I run the code it doesnt show any plot and I get the following errors:

    Traceback (most recent call last):
    File "C:\Users\Rob\PycharmProjects\pythonProject2\Test.py", line 9, in <module>
    plt.show()
    File "C:\Users\Rob\PycharmProjects\pythonProject2\venv\lib\site-packages\matplotlib\pyplot.py", line 614, in show
    return _get_backend_mod().show(*args, **kwargs)
    File "C:\Program Files\JetBrains\PyCharm 2023.2.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 29, in __call__
    manager.show(**kwargs)
    File "C:\Program Files\JetBrains\PyCharm 2023.2.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 112, in show
    self.canvas.show()
    File "C:\Program Files\JetBrains\PyCharm 2023.2.3\plugins\python\helpers\pycharm_matplotlib_backend\backend_interagg.py", line 73, in show
    buffer = self.tostring_rgb()
    AttributeError: 'FigureCanvasInterAgg' object has no attribute 'tostring_rgb'. Did you mean: 'tostring_argb'?

    Process finished with exit code 1


    How can I fix this?

    Continue reading...

Compartilhe esta Página