ModuleNotFoundError: No module named '_bz2'

  File "/usr/local/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/local/lib/python3.7/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/local/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/opt/deployment/venv/lib/python3.7/site-packages/prodigy/__init__.py", line 9, in <module>
    from . import recipes  # noqa
  File "/opt/deployment/venv/lib/python3.7/site-packages/prodigy/recipes/__init__.py", line 4, in <module>
    from . import dep, ner, textcat, pos, compare, terms, generic, image  # noqa
  File "/opt/deployment/venv/lib/python3.7/site-packages/prodigy/recipes/dep.py", line 12, in <module>
    from ..components.loaders import get_stream
  File "cython_src/prodigy/components/loaders.pyx", line 4, in init prodigy.components.loaders
  File "/usr/local/lib/python3.7/bz2.py", line 19, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
    ModuleNotFoundError: No module named '_bz2'

I am getting the above when I am trying to use any of the prodigy commands. Checked stackoverflow none of them are working. Please can you help us out.
prodigy stats -l
prodigy dataset temp ‘temp db’

Hmm, it looks like the error message you copy-pasted might be cut off? Is there a last line that shows what exactly fails?

It looks like your OS is probably missing the BZ2 decompression library. I think I provided the following list of Ubuntu packages in the other thread. I’m not sure what the CentOS equivalents are, but you should double-check you have the equivalents installed on your servers, to make sure everything works smoothly:

  • unzip
  • libssl-dev
  • zlib1g-dev
  • libbz2-dev
  • libreadline-dev
  • libsqlite3-dev
  • wget
  • curl
  • llvm
  • libncurses5-dev
  • libncursesw5-dev
  • xz-utils
  • python-pip
  • python-virtualenv
  • python3-pip
  • python3-venv
  • python-dev
  • python3-dev
  • libopenblas-base
  • libopenblas-dev

updated the last line

I have the same issue on debian python 3.8.1. I could apt install all the packages mentioned by @honnibal. @vajja did you manage to solve it or did you change OS?

@nix411 Did you reinstall/recompile Python afterwards? The issue seems to be pretty common (see here) and the solution typically involves installing BZ2 and then reconfiguring and recompiling Python.

1 Like