"ImportError: No module named bz2"의 두 판 사이의 차이

 
(다른 사용자 한 명의 중간 판 2개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==문제상황==
==문제상황==
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki pywikipedia]# python category.py move
[root@zetawiki pywikipedia]# python category.py move
Traceback (most recent call last):
Traceback (most recent call last):
6번째 줄: 6번째 줄:
     import os, re, pickle, bz2
     import os, re, pickle, bz2
ImportError: No module named bz2
ImportError: No module named bz2
</source>
</syntaxhighlight>
:→ bz2 모듈이 인식되지 않음
:→ bz2 모듈이 인식되지 않음


==해결방법==
==해결방법==
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# rpm -qa | grep bzip2-devel
[root@zetawiki ~]# rpm -qa | grep bzip2-devel
[root@zetawiki ~]#  
[root@zetawiki ~]#  
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# yum install bzip2-devel
[root@zetawiki ~]# yum install bzip2-devel
... (생략)
... (생략)
30번째 줄: 30번째 줄:
Installed size: 412 k
Installed size: 412 k
Is this ok [y/N]: y
Is this ok [y/N]: y
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
Installed:
Installed:
   bzip2-devel.x86_64 0:1.0.5-7.el6_0                                                                   
   bzip2-devel.x86_64 0:1.0.5-7.el6_0                                                                   


Complete!
Complete!
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# rpm -qa | grep bzip2-devel
[root@zetawiki ~]# rpm -qa | grep bzip2-devel
bzip2-devel-1.0.5-7.el6_0.x86_64
bzip2-devel-1.0.5-7.el6_0.x86_64
</source>
</syntaxhighlight>
*[[Python 2.7 설치]] 참고하여 Python 설치(또는 재설치)
*[[Python 2.7 설치]] 참고하여 Python 설치(또는 재설치)


==확인 (성공)==
==확인 (성공)==
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# /usr/bin/python -c "import bz2; print bz2.__doc__"
[root@zetawiki ~]# /usr/bin/python -c "import bz2; print bz2.__doc__"
The python bz2 module provides a comprehensive interface for
The python bz2 module provides a comprehensive interface for
50번째 줄: 50번째 줄:
interface, one shot (de)compression functions, and types for
interface, one shot (de)compression functions, and types for
sequential (de)compression.
sequential (de)compression.
</source>
</syntaxhighlight>
:→ bz2 모듈 인식됨
:→ bz2 모듈 인식됨


==확인 (실패)==
==확인 (실패)==
여전히 안됨
여전히 안됨
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -V
[root@zetawiki ~]# python -V
Python 2.7.9
Python 2.7.9
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -c "import bz2; print bz2.__doc__"
[root@zetawiki ~]# python -c "import bz2; print bz2.__doc__"
Traceback (most recent call last):
Traceback (most recent call last):
   File "<string>", line 1, in <module>
   File "<string>", line 1, in <module>
ImportError: No module named bz2
ImportError: No module named bz2
</source>
</syntaxhighlight>


==실패시 조치==
==실패시 조치==
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# rpm -ql python-libs | grep bz2.so
[root@zetawiki ~]# rpm -ql python-libs | grep bz2.so
/usr/lib64/python2.6/lib-dynload/bz2.so
/usr/lib64/python2.6/lib-dynload/bz2.so
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# cp /usr/lib64/python2.6/lib-dynload/bz2.so /usr/local/lib/python2.7/lib-dynload/
[root@zetawiki ~]# cp /usr/lib64/python2.6/lib-dynload/bz2.so /usr/local/lib/python2.7/lib-dynload/
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -c "import bz2; print bz2.__doc__"
[root@zetawiki ~]# python -c "import bz2; print bz2.__doc__"
The python bz2 module provides a comprehensive interface for
The python bz2 module provides a comprehensive interface for
80번째 줄: 80번째 줄:
interface, one shot (de)compression functions, and types for
interface, one shot (de)compression functions, and types for
sequential (de)compression.
sequential (de)compression.
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
86번째 줄: 86번째 줄:
*[[미디어위키봇 가리키는 문서에 분류 추가]]
*[[미디어위키봇 가리키는 문서에 분류 추가]]


==참고 자료==
==참고==
*http://stackoverflow.com/questions/8115280/importerror-no-module-named-bz2-for-python-2-7-2
*http://stackoverflow.com/questions/8115280/importerror-no-module-named-bz2-for-python-2-7-2


[[분류: Python]]
[[분류: ImportError]]
[[분류: ImportError]]
[[분류: import bz2]]

2020년 12월 27일 (일) 13:20 기준 최신판

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 }}