Skip to content

Importerror with matplotlib > 3.7 "cannot import name 'common_texification' from 'matplotlib.backends.backend_pgf'" #595

Closed as not planned
@JohannesAck

Description

@JohannesAck

Please provide a minimal working example (MWE) that shows what isn't working as
expected. Needed is

  • the Python code,
import tikzplotlib
  • the output
  File "/workspaces/jax_rl_tests/tikzplotlibdebug.py", line 12, in <module>
    import tikzplotlib
  File "/usr/local/lib/python3.10/dist-packages/tikzplotlib/__init__.py", line 5, in <module>
    from ._save import Flavors, get_tikz_code, save
  File "/usr/local/lib/python3.10/dist-packages/tikzplotlib/_save.py", line 11, in <module>
    from . import _axes
  File "/usr/local/lib/python3.10/dist-packages/tikzplotlib/_axes.py", line 3, in <module>
    from matplotlib.backends.backend_pgf import (
ImportError: cannot import name 'common_texification' from 'matplotlib.backends.backend_pgf' (/usr/local/lib/python3.10/dist-packages/matplotlib/backends/backend_pgf.py)

It seems tikzplotlib is using a deprecated API, which was made internal from matplotlib>3.7.

An easy workaround right now is to downgrade to matplotlib before 3.5.

To fix, it would probably possible to use the (internal) _escape_tex API.
https://github.com/matplotlib/matplotlib/blob/336028f4d521a23d9ea2de88b1faf82eddfa5b52/lib/matplotlib/backends/backend_pgf.py#L101

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions