ImportError: No module named bz2 for Python 2.7.2

I meet the same problem, here’s my solution.

The reason of import error is while you are building python, system couldn’t find the bz2 headers and skipped building bz2 module.

Install them on Ubuntu/Debian:

sudo apt-get install libbz2-dev

Fedora:

sudo yum install bzip2-devel

and then rebuild python

comes from another answer

@birryree’s answer helps to back to the system’s original python.

Leave a Comment