raphaelm / python-sepaxml

SEPA Direct Debit XML generation in python
MIT License
110 stars 41 forks source link

Exception "cannot import name 'Counter'" when calling export(validate=True) #43

Closed jacopsd closed 2 years ago

jacopsd commented 2 years ago

Version: sepaxml==2.5.0

Got following exception when calling "export(validate=True)"

2022-01-13 18:05:28 [13/Jan/2022 18:05:28] ERROR [sepa_xml:42] Exception: cannot import name 'Counter' 

Traceback (most recent call last):
#012  File "./prj/sepa_xml.py", line 38, in generate_sepa_xml
#012    return _sepa.export(validate=True)
#012  File "/home/user/.virtualenvs/EXP3.6/lib/python3.6/site-packages/sepaxml/shared.py", line 99, in export
#012    try_valid_xml(out, self.schema)
#012  File "/home/user/.virtualenvs/EXP3.6/lib/python3.6/site-packages/sepaxml/validation.py", line 9, in try_valid_xml
#012    import xmlschema  # xmlschema does some weird monkeypatching in etree, if we import it globally, things fail
#012  File "/home/user/.virtualenvs/EXP3.6/lib/python3.6/site-packages/xmlschema/__init__.py", line 20, in <module>
#012    from .dataobjects import DataElement, DataElementConverter, DataBindingConverter
#012  File "/home/user/.virtualenvs/EXP3.6/lib/python3.6/site-packages/xmlschema/dataobjects.py", line 27, in <module>
#012    from . import validators
#012  File "/home/user/.

Seems that global_maps.py within xmlschema has this line: from collections import Counter

So probably that one fails, but why?

raphaelm commented 2 years ago

Sounds like a broken Python setup on your end, collections.Counter is a standard library module and should always exist

jacopsd commented 2 years ago

OK, thank you for your help. This can be closed.

jacopsd commented 2 years ago

Found the cause: python3.6.0 does not have "Counter" in the typing library