SOLUTION: ValueError: bad marshal data (unknown type code)

The error: bad marshal data

When you try to install a python package you get the error:

Traceback (most recent call last):
from sqlalchemy.ext.declarative import declarative_base
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/__init__.py", line 8, in <module>
from .api import declarative_base, synonym_for, comparable_using, \
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/api.py", line 11, in <module>
from ...orm import synonym as _orm_synonym, \
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/__init__.py", line 17, in <module>
from .mapper import (
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 27, in <module>
from . import properties
ValueError: bad marshal data (unknown type code)

Solution!

Check the traceback path and delete all the pycs files recursively:

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

In our case the path was "/usr", howevery it could be inside your virtualenv.