'bz2 is module not available' when installing Pandas with pip in python virtual environment

qAp picture qAp · Mar 12, 2014 · Viewed 21.4k times · Source

I am going through this post Numpy, Scipy, and Pandas - Oh My!, installing some python packages, but got stuck at the line for installing Pandas:

pip install -e git+https://github.com/pydata/pandas#egg=pandas

I changed 'wesm' to 'pydata' for the latest version, and the only other difference to the post is that I'm using pythonbrew.

I found this post, related to the error, but where is the Makefile for bz2 mentioned in the answer? Is there another way to resolve this problem?

Any help would be much appreciated. Thanks.

Answer

Freek Wiekmeijer picture Freek Wiekmeijer · Mar 12, 2014

You need to build python with BZIP2 support.

Install the following package before building python:

  • Red Hat/Fedora/CentOS: yum install bzip2-devel
  • Debian/Ubuntu: sudo apt-get install libbz2-dev

Extract python tarball. Then

configure;
make;
make install

Install pip using the new python.

Alternative:

Install a binary python distribution using yum or apt, that was build with BZIP2 support.

See also: ImportError: No module named bz2 for Python 2.7.2