2

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.

Phlip
  • 5,253
  • 5
  • 32
  • 48

2 Answers2

2

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

apt-get install libbz2-dev
falsetru
  • 357,413
  • 63
  • 732
  • 636
  • thanks from the community - SEO will now match the above error message to standard channels, so anyone with the error message gets the exact answer. This is only not the correct answer from the page bc "we must go deeper." I installed that library package a while ago by reflex, hence something else in my stack (django17, Raspbian, RPI, pythonbrew, python3.4.1, etc.) must be at fault. – Phlip Jan 02 '15 at 02:53
  • What happens if you already had Python installed? – Jackie May 18 '21 at 14:02
1

The "winning" answer is to erase your .pythonbrew folder and build again. Put another way, Python had trouble seeing Aptitude -dev packages installed after pythonbrew built it.

Nobody upvote it plz, bc it's still just a sucky workaround!

Phlip
  • 5,253
  • 5
  • 32
  • 48