ImportError: No module named bz2

1 문제상황[ | ]

[root@zetawiki pywikipedia]# python category.py move
Traceback (most recent call last):
  File "category.py", line 99, in <module>
    import os, re, pickle, bz2
ImportError: No module named bz2
→ bz2 모듈이 인식되지 않음

2 해결방법[ | ]

[root@zetawiki ~]# rpm -qa | grep bzip2-devel
[root@zetawiki ~]#
[root@zetawiki ~]# yum install bzip2-devel
... (생략)
======================================================================================================
 Package                   Arch                 Version                      Repository          Size
======================================================================================================
Installing:
 bzip2-devel               x86_64               1.0.5-7.el6_0                base               250 k

Transaction Summary
======================================================================================================
Install       1 Package(s)

Total download size: 250 k
Installed size: 412 k
Is this ok [y/N]: y
Installed:
  bzip2-devel.x86_64 0:1.0.5-7.el6_0                                                                  

Complete!
[root@zetawiki ~]# rpm -qa | grep bzip2-devel
bzip2-devel-1.0.5-7.el6_0.x86_64

3 확인 (성공)[ | ]

[root@zetawiki ~]# /usr/bin/python -c "import bz2; print bz2.__doc__"
The python bz2 module provides a comprehensive interface for
the bz2 compression library. It implements a complete file
interface, one shot (de)compression functions, and types for
sequential (de)compression.
→ bz2 모듈 인식됨

4 확인 (실패)[ | ]

여전히 안됨

[root@zetawiki ~]# python -V
Python 2.7.9
[root@zetawiki ~]# python -c "import bz2; print bz2.__doc__"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named bz2

5 실패시 조치[ | ]

[root@zetawiki ~]# rpm -ql python-libs | grep bz2.so
/usr/lib64/python2.6/lib-dynload/bz2.so
[root@zetawiki ~]# cp /usr/lib64/python2.6/lib-dynload/bz2.so /usr/local/lib/python2.7/lib-dynload/
[root@zetawiki ~]# python -c "import bz2; print bz2.__doc__"
The python bz2 module provides a comprehensive interface for
the bz2 compression library. It implements a complete file
interface, one shot (de)compression functions, and types for
sequential (de)compression.

6 같이 보기[ | ]

7 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}