Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml.etree.ElementTree.ParseError: syntax error: line 1, column 0 (and temporary solution) #107

Open
Elteoremadebeethoven opened this issue Dec 19, 2024 · 0 comments

Comments

@Elteoremadebeethoven
Copy link

I have this error using Fedora 40, python3.11 and python3.12 when using LaTeX:

  File "/home/zavden/Manim/mgl_test/manimlib/mobject/svg/svg_mobject.py", line 128, in mobjects_from_svg_string
    element_tree = ET.ElementTree(ET.fromstring(svg_string))
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/xml/etree/ElementTree.py", line 1335, in XML
    parser.feed(text)
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0

In svg_mobject.py, line 128 I printed the variable "svg_string", and I noticed that this message was printed before the xml:

The old, written in PostScript, PDF interpreter has been removed entirely.
You should cease using -dNEWDPF as it has no effect n<?xml version='1.0' encoding='UTF-8'?>

I don't know how to solve it directly using ET, so I solved it by removing that text manually (line 127):

    def mobjects_from_svg_string(self, svg_string: str) -> list[VMobject]:
        header_in_xml = svg_string.find("<?xml") #
        if header_in_xml != -1: #
          svg_string = svg_string[header_in_xml:] #
        element_tree = ET.ElementTree(ET.fromstring(svg_string))

And this solves the bug, but if anyone has a more elegant solution using ET, feel free to comment.

Thank you,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant