question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pypi install fails with `ValueError: bad marshal data (unknown type code)`

See original GitHub issue

Virtually identical to https://github.com/jasmine/jasmine-py/issues/30 and https://github.com/tomchristie/django-rest-framework/issues/1804

I’m running a python 3.6.0 virtualenv. I can install newspaper3k without a problem via pip install newspaper3k.

However, it fails when I add newspaper3k to install_requires in my setup.py script:

setup.py:

...
setup(
    ...
    install_requires=[
        'newspaper3k'
    ]
)

error on `python setup.py develop’:

running develop
running egg_info
...
Searching for jieba3k>=0.35.1
Reading https://pypi.python.org/simple/jieba3k/
Downloading https://pypi.python.org/packages/a9/cb/2c8332bcdc14d33b0bedd18ae0a4981a069c3513e445120da3c3f23a8aaa/jieba3k-0.35.1.zip#md5=e09c3b5c9dfbb285be11802257e642c2
Best match: jieba3k 0.35.1
Processing jieba3k-0.35.1.zip
Writing /var/folders/kb/xwpc5_xj3bs00j82888rghjr0000gn/T/easy_install-i0h5fjyv/jieba3k-0.35.1/setup.cfg
Running jieba3k-0.35.1/setup.py -q bdist_egg --dist-dir /var/folders/kb/xwpc5_xj3bs00j82888rghjr0000gn/T/easy_install-i0h5fjyv/jieba3k-0.35.1/egg-dist-tmp-5toh92if
zip_safe flag not set; analyzing archive contents...
Traceback (most recent call last):
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 157, in save_modules
    yield saved
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 255, in run_setup
    DirectorySandbox(setup_dir).run(runner)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 285, in run
    return func()
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 253, in runner
    _execfile(setup_script, ns)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 47, in _execfile
    exec(code, globals, locals)
  File "/var/folders/kb/xwpc5_xj3bs00j82888rghjr0000gn/T/easy_install-i0h5fjyv/jieba3k-0.35.1/setup.py", line 10, in <module>
    Requires:
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 209, in run
    os.path.join(archive_root, 'EGG-INFO'), self.zip_safe()
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 245, in zip_safe
    return analyze_egg(self.bdist_dir, self.stubs)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 355, in analyze_egg
    safe = scan_module(egg_dir, base, name, stubs) and safe
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 392, in scan_module
    code = marshal.load(f)
ValueError: bad marshal data (unknown type code)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 89, in <module>
    'newspaper3k'
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/develop.py", line 36, in run
    self.install_for_development()
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/develop.py", line 150, in install_for_development
    self.process_distribution(None, self.dist, not self.no_deps)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 747, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 851, in resolve
    dist = best[req.key] = env.best_match(req, ws, installer)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1123, in best_match
    return self.obtain(req, installer)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1135, in obtain
    return installer(requirement)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 674, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 700, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 881, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1120, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1106, in run_setup
    run_setup(setup_script, args)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 258, in run_setup
    raise
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 100, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 100, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 169, in save_modules
    saved_exc.resume()
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 144, in resume
    six.reraise(type, exc, self._tb)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 157, in save_modules
    yield saved
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 198, in setup_context
    yield
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 255, in run_setup
    DirectorySandbox(setup_dir).run(runner)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 285, in run
    return func()
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 253, in runner
    _execfile(setup_script, ns)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/sandbox.py", line 47, in _execfile
    exec(code, globals, locals)
  File "/var/folders/kb/xwpc5_xj3bs00j82888rghjr0000gn/T/easy_install-i0h5fjyv/jieba3k-0.35.1/setup.py", line 10, in <module>
    Requires:
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 209, in run
    os.path.join(archive_root, 'EGG-INFO'), self.zip_safe()
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 245, in zip_safe
    return analyze_egg(self.bdist_dir, self.stubs)
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 355, in analyze_egg
    safe = scan_module(egg_dir, base, name, stubs) and safe
  File "/Users/romanhartmann/.virtualenvs/testenv3/lib/python3.6/site-packages/setuptools/command/bdist_egg.py", line 392, in scan_module
    code = marshal.load(f)
ValueError: bad marshal data (unknown type code)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
codelucascommented, May 16, 2017

Hey @RomHartmann thank you for reporting this bug, we just merged a change into master. By tonight the master branch will be hot-pushed into pip and you can reinstall and re-attempt!

For now, if you are in a hurry, consider pulling github master and reinstalling that way.

0reactions
Collen-Rollercommented, Feb 1, 2019

I’m having an identical issue to this still. Working with Python 3.6 and attempting to use newspaper3k as a dependency.

setup(
    ...
    install_requires=[
        'newspaper3k'
    ]
). 

The error is as follows: ValueError: bad marshal data (unknown type code)

Not sure how to fix this but it appears that jieba3k-0.35.1/setup.py is the source of the issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

easy_install ValueError: bad marshal data (unknown type code)
This guy who reported the issue says that he solved this error by removing pycache. I tried searching pycache and removing all folders...
Read more >
Error: ValueError: Bad marshal data when running Python script
A .pyc file ('compiled' Python file) in the Python install folder has become corrupt. These files are used by Python to speed up...
Read more >
pypi install fails with `ValueError: bad marshal data (unknown type ...
pypi install fails with `ValueError: bad marshal data (unknown type code)` ... I'm running a python 3.6.0 virtualenv. I can install newspaper3k *without...
Read more >
Bad marshal data when calling help() - Raspberry Pi Forums
The issue is apparently created by corrupt .pyc files (python files!) .pyc files are generated when python code is run, it often tricky...
Read more >
ValueError: bad marshal data (unknown type code) - white page
コンパイルでこけて以下のエラーメッセージを吐く。 ... globalとanaconda local以下のpycを全て削除してみたがやっぱり進まず。 ... をやってみたらなぜか ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found