[Python] Tikzplotlib module throws attribute error: module 'webcolors' has no attribute...

Discussão em 'Python' iniciado por Stack, Maio 20, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to convert matplotlib figures to PGFPlots/Tikz figures while using the module tikzplotlib:

    import matplotlib.pyplot as plt
    import numpy as np
    import tikzplotlib

    x = np.linspace(0, 2*np.pi, 51)
    y = np.sin(x)

    plt.plot(x, y)
    plt.xlabel("x")
    plt.ylabel("y")

    tikzplotlib.save('test.tex')


    When I run this code, I get an attribute error:

    AttributeError: module 'webcolors' has no attribute 'CSS3_HEX_TO_NAMES'


    The documentations of tikzplotlib and webcolors did not give me an idea to solve this.

    I have found related questions(1, 2) to the described attribute error from the webcolors module without a solution for me.

    Is someone able to reproduce this error or knows a solution for this?

    I am working with python 3.9.5, webcolors 24.6.0 and tikzplotlib 0.10.1 in Visual Studio Code Version 1.90.2 on Windows 11.

    Continue reading...

Compartilhe esta Página