Corrupted .py file?

Running into this error and have no idea what is going on

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 17, in <module>
    from pkgutil import read_code, get_importer
  File "/usr/local/lib/python3.7/pkgutil.py", line 137, in <module>
    def iter_importer_modules(importer, prefix=''):
  File "/usr/local/lib/python3.7/functools.py", line 762, in singledispatch
    import types, weakref
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 857, in get_code
  File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
Could not import runpy module
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 17, in <module>
    from pkgutil import read_code, get_importer
  File "/usr/local/lib/python3.7/pkgutil.py", line 137, in <module>
    def iter_importer_modules(importer, prefix=''):
  File "/usr/local/lib/python3.7/functools.py", line 762, in singledispatch
    import types, weakref
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 857, in get_code
  File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)

Have you tried the accepted answer in this SO thread?

Apologies for novice understanding. Will that command work for hassio?

  • So just go to root on my hassio
  • type:
find /usr -name '*.pyc' -delete
  • restart the pi?

You don’t have to go to the root specifically as you are passing on the ‘start location’ in the command, which is ‘/usr’ in this case.

You can find some example on what the find command is here.

Basically what the command does is find all files in the directory /usr and subdirectories where the name ends in .pyc (which is a compiled python class file) and then delete it.

I have no knowledge on where Hass.io stores its files as I’m just using HA in a docker container. What you can do is do the command without -delete first to see what shows up, as a dry run. If it looks OK, you can redo the command with the -delete at the end.

Have you fix your problem?

I was unable to fix it unfortunately. I ended up just backing up to another sd card with a snapshot. Not sure what caused the problem and I’m not savvy enough to figure it out