2012-09-09 19 views
7

我正在安裝一個新的mac,我一直在嗡嗡聲,安裝pip和一些軟件包。當突然,每個PIP命令我嘗試運行會拋出pip給「ImportError:沒有名爲setuptools的模塊」,但我可以在python解釋器中導入setuptools

Exception: 
Traceback (most recent call last): 
    File "/Library/Python/2.6/site-packages/pip-1.2.1-py2.6.egg/pip/basecommand.py", line 107, in main 
    status = self.run(options, args) 
    File "/Library/Python/2.6/site-packages/pip-1.2.1-py2.6.egg/pip/commands/install.py", line 248, in run 
    import setuptools 
ImportError: No module named setuptools 

我算了一下,不小心刪除一個目錄或什麼的,所以我嘗試重新安裝setuptools的,下面的other answers本網站上的意見。我從here下載了setuptools egg,並像shell腳本那樣運行它。得到這個輸出:

Processing setuptools-0.6c11-py2.7.egg 
Removing /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg 
Copying setuptools-0.6c11-py2.7.egg to /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages 
setuptools 0.6c11 is already the active version in easy-install.pth 
Installing easy_install script to /Library/Frameworks/Python.framework/Versions/2.7/bin 
Installing easy_install-2.7 script to /Library/Frameworks/Python.framework/Versions/2.7/bin 

Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg 
Processing dependencies for setuptools==0.6c11 
Finished processing dependencies for setuptools==0.6c11 

現在,如果我開始一個交互式的Python會話,我可以import setuptools沒有錯誤,但PIP(和其他命令行腳本)抱怨說,它沒有安裝。任何想法爲什麼Python似乎找到它,但不是其他腳本?

如果有幫助,這是什麼在sys.path

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages 
+1

請注意,您的pip錯誤顯示跟蹤中的Python 2.6,但其餘部分正在使用Python 2.7您的pip頂級腳本的頂部行是什麼樣的? – Keith

回答

7

pip似乎並沒有要與你的Python協議。比較:

File "/Library/Python/2.6/site-packages/pip-1.2.1-py2.6.egg/pip/basecommand.py", line 107, in main 

Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg 

如果python2.7有setuptools的,那麼你應該有

/Library/Frameworks/Python.framework/Versions/2.7/bin/easy_install-2.7 

可用,在這種情況下

easy_install-2.7 pip 

應該給你pip-2.7

+2

我意識到實際問題只是在安裝Python 2.7後需要重新啓動。當我從2.6升級時,有些東西沒有正確清理。但指定使用哪一個'easy_install'也可以做到這一點。 –

相關問題