Skip to content

AttributeError: 'NoneType' object has no attribute 'encoding' #106

Description

@cedricscheepers

Hi

I trust you can help me. I am successfully extracting MT940 from a text file, on Mac and Windows. When I then use PyInstaller to create an exe (on Windows), I get the following error (but not in my IDE) and traceback:

File "modules\gui.py", line 550, in __on_timer
  File "modules\playbot.py", line 284, in run
  File "modules\playbot.py", line 1984, in _run_process
  File "modules\playbot.py", line 2035, in __call_function
  File "modules\playbot.py", line 1037, in _extract_mt940
  File "modules\files.py", line 454, in file_open_mt940
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
  File "mt940\__init__.py", line 3, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
  File "mt940\json.py", line 7, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
  File "mt940\models.py", line 13, in <module>
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 391, in exec_module
  File "mt940\_compat.py", line 117, in <module>
AttributeError: 'NoneType' object has no attribute 'encoding'

As I've mentioned, this works when my app is not an executable, but fails when it is.

In case it helps, here is my code where I catch this exception:

    try:
        transactions = mt940.parse(path)

        return loads(dumps(transactions, cls=mt940.JSONEncoder))
    except Exception as err:
        return err

I look forward to hearing from you.

Kind regards
Cedric

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions