missing python bz2 module

Probably as you built python from source, you don't have bz2 headers.

Install them on Ubuntu/Debian:

sudo apt-get install libbz2-dev

Fedora:

sudo yum install bzip2-devel 

And build python again. You may notice that python checks for lots of libraries when configuring/building, if you miss some of them you probably will get no support for libs like bz2 on your case.

You should get prebuild binaries to avoid this kind of stuff. Ubuntu 12.04 packs python 2.7.3, the version your script needs.


I had this happen for python 3.8.2 when importing pandas: import pandas as pd

resulted in a long error message ending with: "error: ModuleNotFoundError: No module named '_bz2'"

This was resolved by doing the following 2 bash commands:

sudo apt-get install libbz2-dev
sudo cp /usr/lib/python3.8/lib-dynload/_bz2.cpython-38-x86_64-linux-gnu.so  /usr/local/lib/python3.8/

Then it worked fine.


On CentOS 7, install bzip2-devel:

sudo yum install  bzip2-devel

Then re-compile python.