[Python] executing python code in wsl (ubuntu) takes unreasonably too long time and gives...

Discussão em 'Python' iniciado por Stack, Abril 29, 2025.

  1. Stack

    Stack Membro Participativo

    I have a simple python code, only 4 lines of code.

    from matplotlib import pyplot as plt
    import matplotlib
    plt.plot([1,2,3], [4,2,4])
    plt.show()


    I am using visual studio code with wsl2 (Ubuntu 22-04) terminal for execution. I also use XLaunch for using the plt.show() function in wsl.

    When I execute the code, it takes a long time, and finally it gives me the following warning:

    UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
    plt.show()


    I have configured before the XLaunch and vscode via this link https://stackoverflow.com/questions/43397162/show-matplotlib-plots-and-other-gui-in-ubuntu-wsl1-wsl2and it was working nice, but now I don't know what have changed and why the execution is talking too long time. thanks in advance.

    what I did is to add this line matplotlib.use('qt5agg') but it didn't solve it.

    Continue reading...

Compartilhe esta Página