Search code examples
pythondebianraspberry-pibzip2pythonbrew

pythonbrew importing bz2 yields: ImportError: No module named '_bz2'


This wtf happens on a Debian, during some dumb pip install, in python3.4.1

Traceback (most recent call last):
  File "/home/pi/.pythonbrew/pythons/Python-3.4.1/lib/python3.4/tarfile.py", line 1640, in bz2open
    import bz2
  File "/home/pi/.pythonbrew/pythons/Python-3.4.1/lib/python3.4/bz2.py", line 20, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
ImportError: No module named '_bz2'

Unless someone nails this early & easy, I will return next year to emblandish it with boredom like which RaspberryPI Debian it is.

Anyhoozle, the junior answer is apt-get install libbz2-dev tx to @falsetru for finishing the FAQ segments of tonight's entertainment. However, we seem to have aptitude installed a bunch of random filenames ending in -dev recently:

$ aptitude search libbz2
i   libbz2-1.0    
i   libbz2-dev

So now I gotta make the question harder. If I guess the RaspberryPi itself is not at fault (this sh*t swings like Tarzan on my WinPython3.3, 64-beet), then maybe pythonbrew dunnit.


Solution

  • You need to install libbz2-dev package before install Python to build bz2 module.

    apt-get install libbz2-dev