在安装node.js时提示ImportError: No module named bz2。

很明显这个python中没有装bz2的库导致的。

解决方法:

sudo apt-get install libbz2-dev

然后需要重新编译一下python,就可以了。以下是如何编译安装Python 2.7.5

环境:

Ubuntu 12.04.2 64位

chenzc2@T530:~/Downloads$ uname -a

Linux T530 3.5.0-23-generic #35-Ubuntu SMP Fri Jan 25 17:13:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

获取源码:

chenzc2@T530:~/Downloads$ wget http://www.python.org/ftp/python/2.7.5/Python-2.7.5.tar.bz2

解压缩:

chenzc2@T530:~/Downloadst$ tar xvf Python-2.7.5.tar.bz2

配置:

chenzc2@T530:~/Downloads$ cd Python-2.7.5/

chenzc2@T530:~/Downloads$ ./configure

编译:

chenzc2@T530:~/Downloads/Python-2.7.5$ sudo make install

测试:

chenzc2@T530:~/Downloads/Python-2.7.5$ python

Python 2.7.5 (default, Jun 29 2013, 13:03:32)

[GCC 4.6.3] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> print "Hello World!"

Hello World!

>>> 1234 * 4321

5332114

>>> import datetime

>>> print datetime.datetime.now()

2013-06-29 13:29:44.838243

>>>exit()

chenzc2@T530:~/Downloads/Python-2.7.5$