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

AttributeError: module 'xml.etree.ElementTree' has no attribute 'cleanup_namespaces' #20

Closed
Suitx opened this issue Jun 5, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Suitx
Copy link

Suitx commented Jun 5, 2023

Hi there, having trouble getting formation to work.

Here is what I've done to run into this issue:

  1. Starting Formation studio and directly saving the dialog window to simple.xml results in errors printed into console
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\hoverset\data\actions.py", line 43, in invoke
    return self._func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\studio\main.py", line 576, in save
    path = self.context.save()
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\studio\feature\design.py", line 811, in save
    path = self.designer.save(new_path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\studio\feature\design.py", line 353, in save
    self.builder.write(self.design_path)
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\studio\parsers\loader.py", line 395, in write
    dump.write(file_loader(node=self.root).generate(**pref.get(pref_path)))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\formation\formats\_xml.py", line 90, in generate
    etree.cleanup_namespaces(x_node, top_nsmap=namespaces)
    ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'xml.etree.ElementTree' has no attribute 'cleanup_namespaces'
  1. Afterwards, running the generated xml results in the following console output:
from formation import AppBuilder
app = AppBuilder(path="simple.xml")
app.mainloop()
Traceback (most recent call last):
  File "C:\Projekte\Lightanimations\Playground\POC_tkinter\test_tkinter.py", line 12, in <module>
    app = AppBuilder(path="simple.xml")
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\formation\loader.py", line 489, in __init__
    super().__init__(self._app, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\formation\loader.py", line 265, in __init__
    self.load_path(self._path)
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\formation\loader.py", line 427, in load_path
    tree.load()
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\formation\formats\_xml.py", line 82, in load
    x_node = etree.parse(file).getroot()
             ^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\xml\etree\ElementTree.py", line 1218, in parse
    tree.parse(source, parser)
  File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\xml\etree\ElementTree.py", line 580, in parse
    self._root = parser._parse_whole(source)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
xml.etree.ElementTree.ParseError: no element found: line 1, column 0

My setup:
image

Any advice what's wrong here?

@Suitx Suitx added the bug Something isn't working label Jun 5, 2023
@ObaraEmmanuel
Copy link
Owner

@Suitx you can install lxml as a quick fix

pip install lxml

ObaraEmmanuel added a commit that referenced this issue Jun 7, 2023
@ObaraEmmanuel
Copy link
Owner

@Suitx there is a new version fixing this issue. If this issue is resolved for you feel free to close it.

@Suitx
Copy link
Author

Suitx commented Jun 7, 2023

Thanks for the super fast response and fix. Works.

@Suitx Suitx closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants