wolph / mt940

A library to parse MT940 files and returns smart Python collections for statistics and manipulation.
https://mt940.readthedocs.org/en/latest/
BSD 3-Clause "New" or "Revised" License
94 stars 50 forks source link

Error using mt940 in fints: module 'mt940' has no attribute 'tags' #77

Closed tmechsner closed 5 years ago

tmechsner commented 5 years ago

I use python-fints to retrieve transactions from a bank account. The latest mt940 version (v4.17.0) is installed. Executing this line (from fints/utils.py, l. 18) transactions = mt940.models.Transactions() results in the following error:

WARNING:fints.client:Dialog response: 3060 - Bitte beachten Sie die enthaltenen Warnungen/Hinweise.
INFO:fints.client:Dialog response: 0020 - Auftrag ausgeführt.
WARNING:fints.client:Dialog response: 3040 - Weitere Informationen liegen vor. (['1f*4i*j7r45*j85io*1353.42'])
INFO:fints.client:Fetching more results (7)...
WARNING:fints.client:Dialog response: 3060 - Bitte beachten Sie die enthaltenen Warnungen/Hinweise.
INFO:fints.client:Dialog response: 0020 - Auftrag ausgeführt.
WARNING:fints.client:Dialog response: 3040 - Weitere Informationen liegen vor. (['1*1e*j7r45*j85io*990.26'])
INFO:fints.client:Fetching more results (8)...
INFO:fints.client:Dialog response: 0010 - Nachricht entgegengenommen.
INFO:fints.client:Dialog response: 0020 - Auftrag ausgeführt.
INFO:fints.client:Fetching done.
Traceback (most recent call last):
  File "/Users/timo/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/182.4505.26/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1664, in <module>
    main()
  File "/Users/timo/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/182.4505.26/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1658, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/Users/timo/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/182.4505.26/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1068, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Users/timo/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-C/ch-0/182.4505.26/PyCharm CE.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/timo/workspace/Spent/_fiddles/Fints.py", line 140, in <module>
    download_transactions(from_date=datetime.date(2018, 1, 1))
  File "/Users/timo/workspace/Spent/_fiddles/Fints.py", line 40, in download_transactions
    transactions = f.get_transactions(account, from_date, balance.date)
  File "/Users/timo/anaconda3/envs/spent/lib/python3.7/site-packages/fints/client.py", line 521, in get_transactions
    statement = mt940_to_array(''.join([seg.statement_booked.decode('iso-8859-1') for seg in responses]))
  File "/Users/timo/anaconda3/envs/spent/lib/python3.7/site-packages/fints/utils.py", line 18, in mt940_to_array
    transactions = mt940.models.Transactions()
  File "/Users/timo/anaconda3/envs/spent/lib/python3.7/site-packages/mt940/models.py", line 277, in __init__
    self.tags = Transactions.defaultTags().copy()
  File "/Users/timo/anaconda3/envs/spent/lib/python3.7/site-packages/mt940/models.py", line 309, in defaultTags
    return mt940.tags.TAG_BY_ID
AttributeError: module 'mt940' has no attribute 'tags'
sommersohn commented 4 years ago

I have the same problem but with "module 'mt940' has no attribute 'models'". What was the solution?

sommersohn commented 4 years ago

Now I did a pip uninstall mt940 and pip uninstall fints and a new pip install fints and now I get also: module 'mt940' has no attribute 'tags. I don't know what to do.

Using Python 3.8 and Fints 3.0.0

wolph commented 4 years ago

One (admittedly confusing) thing to note is that you're installing mt940 not mt-940 (note the -). That's a completely different package which conflicts with this one.

I would suggest making sure you uninstall both and reinstall this package after. Fints depends on this package, not the other one.

pip uninstall -y mt940 mt-940
pip install -U mt-940