Search code examples
pythonmakefileeasy-installbuildout

easy_install ValueError: bad marshal data (unknown type code)


I'm trying to buildout in isolated enviroment and I got this error:

ValueError: bad marshal data (unknown type code)
An error occurred when trying to install djangorestframework-csv 1.3.3. Look above this message for any errors that were output by easy_install.
While:
  Installing django.
  Getting distribution for 'djangorestframework-csv'.
Error: Couldn't install: djangorestframework-csv 1.3.3
make: *** [bin/django] Error 1

I tried googling and found that this exact same issue was reported 5 days ago:

https://github.com/mjumbewu/django-rest-framework-csv/issues/18

This error also occurs when you try to

easy_install djangorestframework-csv==1.3.3

After a little bit more googling I found out that this error happens when there are errornous .pyc files.

This guy who reported the issue says that he solved this error by removing pycache. I tried searching pycache and removing all folders called __pycache__ however it didn't help. Any ideas how to solve this ?


Solution

  • Whomever created the distribution accidentally included the __pycache__ directory in the tarball.

    If you are using the download-cache option in your buildout, you can fix this by opening the downloaded djangorestframework-csv-1.3.3.tar.gz file and deleting the offending directory.

    Find the file in your ${buildout:download-cache}/dist directory, and repackage it without the offending directory:

    tar xzvf djangorestframework-csv-1.3.3.tar.gz
    rm -rf djangorestframework-csv-1.3.3/rest_framework_csv/__pycache__/
    tar czvf djangorestframework-csv-1.3.3.tar.gz djangorestframework-csv-1.3.3
    

    Now run your buildout again, and it'll use the fixed cached file.

    Unfortunately, we cannot use find-links here to point to the fixed distribution as it'll only be used when the index (e.g. PyPI by default) does not have the package as well.