2010-01-29 61 views
6

我剛剛安裝了easy_install,但是我在安裝機械化時遇到問題,我應該在任何時候尋址站點包。在下面的第一個嘗試中,我得到了一個錯誤。在下面的第二次嘗試中,我找到了命令,因爲我確信它已經下載,所以這是很奇怪的。使用easy_install安裝機械化

names-computer:~ names$ cd /Users/names/Desktop/ 
names-computer:~/Desktop names$ sh /Users/names/Desktop/mechanize-0.1.9-py2.5.egg 
/Users/names/Desktop/mechanize-0.1.9-py2.5.egg: /Users/names/Desktop/mechanize-0.1.9-py2.5.egg: cannot execute binary file 

names-computer:~/Desktop names$ easy_install mechanize 
-bash: easy_install: command not found 
+0

使用ActivePython,您只需運行「pypm install mechanize」。無需安裝其他程序(ActivePython也包含easy_install/pip) – 2010-02-27 03:23:19

回答

3

在OS X上,Python解釋器實例通常作爲所謂的Framework構建安裝,這意味着框架內有一個bin目錄,該目錄通常(但不總是)是Python腳本的安裝目標,如easy_install。如果您沒有使用蘋果提供的python(位於/ usr/bin /),它有自己的easy_install實例,則應確保所需python的framework bin目錄位於shell搜索路徑中,並且位於/usr/bin之前。特別是,如果你使用的是由python.org安裝程序安裝的蟒蛇,你的路徑應是這個樣子:

$ echo $PATH 
/Library/Frameworks/Python.framework/Versions/2.6/bin:/usr/bin:/bin 

這保證了適當的easy_install將被首次發現。如果您使用的是MacPorts的蟒蛇,它應該是這樣的:

$ echo $PATH 
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin:/opt/local/bin:/usr/bin:/bin 

編輯:順便問一下,你下載的雞蛋似乎是爲Python 2.5,並從以前的問題來看,你可能會想在python 2.6中使用它。如果你只需要使用命令

$ easy_install mechanize 

它會自動下載正確的雞蛋,如果有的話,或源,並做必要的編譯和安裝步驟。

+0

再次感謝您的回答......我最終使用這一個來解決它。 – Diego 2010-05-20 01:20:13

1

mechanize-0.1.9-py2.5.egg只是一個壓縮文件。此外,你不需要手動下載雞蛋。 easy_install會自動爲您下拉代碼並進行安裝。

您可以使用ez_setup.py(它們提供的引導腳本)安裝easy_install。

2

您無需下載機械裝置即可使用easy_install進行安裝。你只是去:

/path/to/easy_install mechanize 

你的問題是,你實際上沒有調用easy_install。

bash: easy_install: command not found 

只有在系統上爲標準Python安裝easy_install時纔有效。顯然你安裝了一些其他的Python。找出你實際安裝它的地方,並用路徑調用它。完成!

11
apt-get install python-setuptools 

該命令將在Ubuntu上安裝easy_install