Total Pageviews

Friday, 6 December 2013

Couldn't import standard bz2 (incomplete Python install)问题的解决,先编译bzip,从而顺利编译mercurial

when tried to compile mercurial from source,遇到出错提示:
Couldn't import standard bz2 (incomplete Python install).

solution:
build and install bzip2 from source

In the README file of bzip2 package's site:bzip.org, it is explained that under certain platforms, namely those which employ Linux-ELF binaries, you have to build an additional shared object file like shown below:

wget http://bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar xpzf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make
make -f Makefile-libbz2_so
make install PREFIX=/path/to/local # /usr/local by default

The critical bit here is the command below, which produces a shared library Python needs in order to make package bz2 available for Python applications.

make -f Makefile-libbz2_so

Rebuild Python and Mercurial

After installing or building bzip2 from source as shown above, you can rebuild Python, as shown below:

cd Python-2.7.6
./configure
make
make install

After that, try to rebuild Mercurial:(然后,就可顺利编译mercurial了
wget  http://mercurial.selenic.com/release/mercurial-2.8.1.tar.gz
tar zxvf mercurial-2.8.1.tar.gz
cd  mercurial-2.8.1
python setup.py install(或者make all && make install  也行。)

from http://stackoverflow.com/questions/5873544/python-source-install-of-2-6-and-mercurial-bz2-error,
http://stackoverflow.com/questions/8115280/importerror-no-module-named-bz2-for-python-2-7-2/8115329#8115329
http://stackoverflow.com/questions/812781/pythons-bz2-module-not-compiled-by-default
https://github.com/joyent/node/issues/3504 (bz2 and python installation)

在编译完bzip2和重新编译Python-2.7.6后,编译node 也同样不会再出错了。

相关帖子: http://briteming.blogspot.co.uk/2013/11/importerror-no-module-named-sqlite3.html