Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

linux - missing python bz2 module

I have installed at my home directory.

[spatel@~ dev1]$ /home/spatel/python-2.7.3/bin/python -V
Python 2.7.3

I am trying to run one script which required python 2.7.x version, and i am getting missing bz2 error

[spatel@~ dev1]$ ./import_logs.py
Traceback (most recent call last):
  File "./import_logs.py", line 13, in <module>
    import bz2
ImportError: No module named bz2

I have tried to install bz2 module but i got lots of error

 [spatel@dev1 python-bz2-1.1]$ /home/spatel/python-2.7.3/bin/python setup.py install
    ...
    ...
    ...
    bz2.c:1765: error: aBZ_FINISH_OKa undeclared (first use in this function)
    bz2.c:1765: warning: comparison between pointer and integer
    bz2.c:1771: error: aPyMemberDefa has no member named aavail_outa
    bz2.c:1778: error: aPyMemberDefa has no member named anext_outa
    bz2.c:1778: error: aPyMemberDefa has no member named atotal_out_hi32a
    bz2.c:1778: error: aPyMemberDefa has no member named atotal_out_lo32a
    bz2.c:1778: error: invalid operands to binary +
    bz2.c:1778: warning: statement with no effect
    bz2.c:1779: error: aPyMemberDefa has no member named aavail_outa
    bz2.c:1779: error: aPyMemberDefa has no member named anext_outa
    bz2.c:1779: error: invalid operands to binary -
    bz2.c:1779: error: invalid operands to binary -
    bz2.c:1779: warning: statement with no effect
    bz2.c:1783: error: aPyMemberDefa has no member named aavail_outa
    bz2.c:1784: error: aPyMemberDefa has no member named atotal_out_hi32a
    bz2.c:1784: error: aPyMemberDefa has no member named atotal_out_lo32a
    bz2.c:1784: warning: passing argument 2 of a_PyString_Resizea makes integer from pointer without a cast
    error: command 'gcc' failed with exit status 1
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...