[python]CompressionError: bz2 module is not available,,事情是这样的,在ce


事情是这样的,在centos6 上本来是python2.6 然后我下载了一个python2.7.5 安装之后,把默认python修改为python2.7.5版本。


使用pip安装twisted的时候出现

CompressionError: bz2 module is not available 错误的。


sof给出的答案基本都是安装 bzip2, bzip2-devel这种依赖包。

http://stackoverflow.com/questions/812781/pythons-bz2-module-not-compiled-by-default

ubuntu上:

sudo apt-get install libbz2-dev


redhat/centos 上

yum install bzip2-devel


或者有些建议源码安装和重新编译python


我就是照着安装和重新编译python,然后再装twisted,还是报错。


换个方式:

[root@localhost Python-2.7.5]# python -c "import bz2;print bz2"<module 'bz2' from '/usr/local/lib/python2.7/lib-dynload/bz2.so'>[root@localhost Python-2.7.5]# python27 -c "import bz2"Traceback (most recent call last):  File "<string>", line 1, in <module>ImportError: No module named bz2?

原因是多个python版本共存,需要统一python的版本,还要把shell默认的python版本缺少的包补全。

可以参考:http://stackoverflow.com/questions/8115280/importerror-no-module-named-bz2-for-python-2-7-2


零碎经验:

多个python版本混乱的时候用whereis 查找一共有哪些python版本,把最重要用的版本软连接给 /usr/bin/python /bin/python特别是多人,多种环境python使用的情况下,一定要用virtulenv这样的工具,否则python版本和包版本很混乱python版本统一之后,还要统一pip,uwsgi这种命令的版本,否则还是会有奇妙的各种问题

本文出自“orangleliu笔记本”博客,转载请务必保留此出处http://blog.csdn.net/orangleliu/article/details/41081171

作者: orangleliu


[python]CompressionError: bz2 module is not available

评论关闭