1. 程式人生 > >sudo easy_install pip ImportError: No module named extern Mac OS X

sudo easy_install pip ImportError: No module named extern Mac OS X

在 Mac OS X 裡,預設沒有 pip 指令可以使用。

執行 sudo easy_install pip 結果:

Traceback (most recent call last):
 File "/usr/local/bin/easy_install", line 11, in <module>
 load_entry_point('setuptools==33.1.1', 'console_scripts', 'easy_install')()
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 565, in load_entry_point
 return get_distribution(dist).load_entry_point(group, name)
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2697, in load_entry_point
 return ep.load()
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2370, in load
 return self.resolve()
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2376, in resolve
 module = __import__(self.module_name, fromlist=['__name__'], level=0)
 File "build/bdist.macosx-10.12-intel/egg/setuptools/__init__.py", line 10, in <module>
 File "build/bdist.macosx-10.12-intel/egg/setuptools/extern/__init__.py", line 1, in <module>
ImportError: No module named extern

改執行 brew install python

結果是:

Warning: python 2.7.13_1 is already installed

解法:

先執行 :

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

再執行

sudo python get-pip.py

就有 pip 指令可以用了。