How to fix Python ValueError:bad marshal data?

If you get that error, the compiled version of the Python module (the .pyc file) is corrupt probably. Gentoo Linux provides python-updater, but in Debian the easier way to fix: just delete the .pyc file. If you don't know the pyc, just delete all of them (as root):

find /usr -name '*.pyc' -delete

There also appears to have been some sort of regression in setuptools with use with python 3.7. See for an example - https://github.com/pypa/setuptools/issues/1257

Forcing reinstallation of setuptools fixed this issue for me.

sudo pip3 install --upgrade --force-reinstall setuptools

Just delete

/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/properties.pyc

it is corrupt as the text indicates. You'll probably have to do so as root.

After that start (again as root) run python (2.7):

/usr/bin/python -c "import sqlalchemy.orm.properties"

to recreate this .pyc file.

If you don't recreate the .pyc file, your program starts slower than necessary as the .py file takes longer to load than the .pyc (and a normal user cannot write the .pyc file).

Tags:

Python