[Python] How can I create png with matplotlib [duplicate]

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

  1. Stack

    Stack Membro Participativo

    I built a small piece of code to plot some data.

    I built it on my Oracle VirtualBox and it worked.

    I moved it to production, and had the sys admin install the code and the libraries, etc.

    Now the matplotlib.pyplot section is failing.

    I tried a simple snippet

    from matplotlib.pyplot import *
    time = [0, 1, 2, 3]
    position = [0, 100, 200, 300]
    plt.plot(time, position)
    plt.xlabel('Time (hr)')
    plt.ylabel('Position (km)')


    and get...


    qt.qpa.screen: QXcbConnection: Could not connect to display
    ​

    I don't even want to see this on the screen, I just want to create a png for a web site.

    How can the code be re-written to connect to the display?

    Continue reading...

Compartilhe esta Página