"리눅스 pip, easy install 정상화"의 두 판 사이의 차이

(새 문서: ;<nowiki>ImportError: No module named pkg_resources</nowiki> ==문제상황== <source lang='cli'> [root@zetaweb ~]# pip --version Traceback (most recent call last): File "/usr/bin/...)
 
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(사용자 2명의 중간 판 27개는 보이지 않습니다)
1번째 줄: 1번째 줄:
;파이썬 setuptools 모듈 설치
;파이썬 pkg_resources 모듈 설치
;파이썬 모듈 관리 환경 설정
;파이썬 pip, easy_install 깨짐
;ez_setup.py
;<nowiki>ImportError: No module named pkg_resources</nowiki>
;<nowiki>ImportError: No module named pkg_resources</nowiki>
;<nowiki>ImportError: No module named setuptools</nowiki>


==문제상황==
==문제상황==
<source lang='cli'>
<syntaxhighlight lang='console'>
[root@zetaweb ~]# pip --version
[root@zetawiki ~]# pip
Traceback (most recent call last):
Traceback (most recent call last):
   File "/usr/bin/pip", line 5, in <module>
   File "/usr/bin/pip", line 5, in <module>
     from pkg_resources import load_entry_point
     from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
ImportError: No module named pkg_resources
</source>
</syntaxhighlight>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# easy_install
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
</syntaxhighlight>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -c 'import pkg_resources'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named pkg_resources
</syntaxhighlight>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -c 'import setuptools'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named setuptools
</syntaxhighlight>
 
==ez_setup.py==
* ez_setup.py 수행 ( 다운로드 및 설치 진행 스크립트 )
<syntaxhighlight lang='bash'>
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
</syntaxhighlight>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# wget https://bootstrap.pypa.io/ez_setup.py -O - | python
--2016-02-19 19:59:33--  https://bootstrap.pypa.io/ez_setup.py
Resolving bootstrap.pypa.io... 103.245.222.175
Connecting to bootstrap.pypa.io|103.245.222.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12059 (12K) [text/x-python]
Saving to: “STDOUT”
 
100%[=================================================>] 12,059      --.-K/s  in 0s     
 
2016-02-19 19:59:33 (335 MB/s) - written to stdout [12059/12059]
 
Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-20.1.1.zip
... (생략)
Installed /usr/local/lib/python2.7/site-packages/setuptools-20.1.1-py2.7.egg
Processing dependencies for setuptools==20.1.1
Finished processing dependencies for setuptools==20.1.1
</syntaxhighlight>
 
==확인==
<syntaxhighlight lang='console'>
[root@zetawiki ~]# python -c 'import pkg_resources'
[root@zetawiki ~]# python -c 'import setuptools'
[root@zetawiki ~]# easy_install --version
setuptools 20.1.1 from /usr/local/lib/python2.7/site-packages/setuptools-20.1.1-py2.7.egg (Python 2.7)
</syntaxhighlight>
:→ pkg_resources, setuptools 모듈 있고, easy_install 도 정상
<syntaxhighlight lang='console'>
[root@zetawiki ~]# pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3141, in <module>
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3127, in _call_aside
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3154, in _initialize_master_working_set
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 640, in _build_master
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 941, in require
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 828, in resolve
pkg_resources.DistributionNotFound: The 'pip==7.1.0' distribution was not found and is required by the application
</syntaxhighlight>
:→ 그런데 pkg_resources 모듈이 pip 버전을 지원하지 못함
 
==pip 재설치==
* 이제 easy_install은 정상작동한다.
* yum으로 설치된 기존의 pip는 삭제하고 easy_install로 다시 설치하자.
<syntaxhighlight lang='console'>
[root@zetawiki ~]# yum remove python-pip
.. (생략)
===========================================================================================
Package                Arch              Version                Repository        Size
===========================================================================================
Removing:
python-pip            noarch            7.1.0-1.el6            @epel            6.6 M
 
Transaction Summary
===========================================================================================
Remove        1 Package(s)
 
Installed size: 6.6 M
Is this ok [y/N]: y
</syntaxhighlight>
<syntaxhighlight lang='console'>
... (생략)
Removed:
  python-pip.noarch 0:7.1.0-1.el6                                                         
 
Complete!
</syntaxhighlight>
* easy_install pip 설치
<syntaxhighlight lang='console'>
[root@zetawiki ~]# easy_install pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 8.0.2
... (생략)
Installed /usr/local/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
</syntaxhighlight>
 
==경로 바로잡기==
<syntaxhighlight lang='console'>
[root@zetawiki ~]# pip --version
-bash: /usr/bin/pip: No such file or directory
</syntaxhighlight>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# which pip
/usr/local/bin/pip
</syntaxhighlight>
<syntaxhighlight lang='console'>
[root@zetawiki ~]# hash -r
[root@zetawiki ~]# pip --version
pip 8.0.2 from /usr/local/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg (python 2.7)
</syntaxhighlight>
 
==같이 보기==
*[[파이썬 모듈 수동 설치]]
*[[pip]]
*[[easy_install]]
*[[setuptools]]


==참고==
* https://bitbucket.org/pypa/setuptools
* http://cheng.logdown.com/posts/2015/06/14/-usr-bin-pip-no-such-file-or-directory


[[분류: pip]]
[[분류: pip]]
[[분류: ImportError]]
[[분류: import pkg_resources]]
[[분류: import setuptools]]

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

파이썬 setuptools 모듈 설치
파이썬 pkg_resources 모듈 설치
파이썬 모듈 관리 환경 설정
파이썬 pip, easy_install 깨짐
ez_setup.py
ImportError: No module named pkg_resources
ImportError: No module named setuptools

1 문제상황[ | ]

[root@zetawiki ~]# pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
[root@zetawiki ~]# easy_install
Traceback (most recent call last):
  File "/usr/bin/easy_install", line 5, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
[root@zetawiki ~]# python -c 'import pkg_resources'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named pkg_resources
[root@zetawiki ~]# python -c 'import setuptools'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named setuptools

2 ez_setup.py[ | ]

  • ez_setup.py 수행 ( 다운로드 및 설치 진행 스크립트 )
wget https://bootstrap.pypa.io/ez_setup.py -O - | python
[root@zetawiki ~]# wget https://bootstrap.pypa.io/ez_setup.py -O - | python
--2016-02-19 19:59:33--  https://bootstrap.pypa.io/ez_setup.py
Resolving bootstrap.pypa.io... 103.245.222.175
Connecting to bootstrap.pypa.io|103.245.222.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12059 (12K) [text/x-python]
Saving to: “STDOUT”

100%[=================================================>] 12,059      --.-K/s   in 0s      

2016-02-19 19:59:33 (335 MB/s) - written to stdout [12059/12059]

Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-20.1.1.zip
... (생략)
Installed /usr/local/lib/python2.7/site-packages/setuptools-20.1.1-py2.7.egg
Processing dependencies for setuptools==20.1.1
Finished processing dependencies for setuptools==20.1.1

3 확인[ | ]

[root@zetawiki ~]# python -c 'import pkg_resources'
[root@zetawiki ~]# python -c 'import setuptools'
[root@zetawiki ~]# easy_install --version
setuptools 20.1.1 from /usr/local/lib/python2.7/site-packages/setuptools-20.1.1-py2.7.egg (Python 2.7)
→ pkg_resources, setuptools 모듈 있고, easy_install 도 정상
[root@zetawiki ~]# pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3141, in <module>
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3127, in _call_aside
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3154, in _initialize_master_working_set
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 640, in _build_master
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 941, in require
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 828, in resolve
pkg_resources.DistributionNotFound: The 'pip==7.1.0' distribution was not found and is required by the application
→ 그런데 pkg_resources 모듈이 pip 버전을 지원하지 못함

4 pip 재설치[ | ]

  • 이제 easy_install은 정상작동한다.
  • yum으로 설치된 기존의 pip는 삭제하고 easy_install로 다시 설치하자.
[root@zetawiki ~]# yum remove python-pip
.. (생략)
===========================================================================================
 Package                Arch               Version                 Repository         Size
===========================================================================================
Removing:
 python-pip             noarch             7.1.0-1.el6             @epel             6.6 M

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

Installed size: 6.6 M
Is this ok [y/N]: y
... (생략)
Removed:
  python-pip.noarch 0:7.1.0-1.el6                                                          

Complete!
  • easy_install pip 설치
[root@zetawiki ~]# easy_install pip
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 8.0.2
... (생략)
Installed /usr/local/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip

5 경로 바로잡기[ | ]

[root@zetawiki ~]# pip --version
-bash: /usr/bin/pip: No such file or directory
[root@zetawiki ~]# which pip
/usr/local/bin/pip
[root@zetawiki ~]# hash -r
[root@zetawiki ~]# pip --version
pip 8.0.2 from /usr/local/lib/python2.7/site-packages/pip-8.0.2-py2.7.egg (python 2.7)

6 같이 보기[ | ]

7 참고[ | ]

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