2011-10-01 104 views
13

我試圖使用easy_install無法使用easy_install的安裝Python模塊

easy_install requests 

安裝一個名爲請求模塊這一個星期前,工作得很好,當我使用Python 2.6.5,但今天我安裝了Python 2.7.2,然後在我的腳本的人試圖import requests但失敗了。然後我嘗試重新安裝與easy_install requests請求,但得到這個錯誤

install_dir /usr/local/lib/python2.6/dist-packages/ 
error: can't create or remove files in install directory 

The following error occurred while trying to add or remove files in the 
installation directory: 

    [Errno 13] Permission denied: '/usr/local/lib/python2.6/dist-packages/test-easy-install-15207.pth' 

The installation directory you specified (via --install-dir, --prefix, or 
the distutils default setting) was: 

    /usr/local/lib/python2.6/dist-packages/ 

Perhaps your account does not have write access to this directory? If the 
installation directory is a system-owned directory, you may need to sign in 
as the administrator or "root" account. If you do not have administrative 
access to this machine, you may wish to choose a different installation 
directory, preferably one that is listed in your PYTHONPATH environment 
variable. 

For information on other options, you may wish to consult the 
documentation at: 

    http://packages.python.org/distribute/easy_install.html 

Please make the appropriate changes for your system and try again. 

所以我被告知去重新安裝的easy_install和我去http://pypi.python.org/pypi/setuptools和教訓,我不得不

刪除所有的setuptools * .egg和setuptools的從 系統的站點包目錄(以及任何其他的sys.path目錄) FIRST .pth文件。

所以我這樣做。然後我重新安裝了setuptools-0.6c11-py2.7.egg的setuptools。這似乎成功,但,當我跑easy_install requests我得到了基本相同的錯誤除了目錄python2.6的/ DIST-包現在python2.7/site-packages中

[email protected]:~$ easy_install requests 
error: can't create or remove files in install directory 

The following error occurred while trying to add or remove files in the 
installation directory: 

    [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/test-easy-install-16253.write-test' 

The installation directory you specified (via --install-dir, --prefix, or 
the distutils default setting) was: 

    /usr/local/lib/python2.7/site-packages/ 

Perhaps your account does not have write access to this directory? If the 
installation directory is a system-owned directory, you may need to sign in 
as the administrator or "root" account. If you do not have administrative 
access to this machine, you may wish to choose a different installation 
directory, preferably one that is listed in your PYTHONPATH environment 
variable. 

For information on other options, you may wish to consult the 
documentation at: 

    http://peak.telecommunity.com/EasyInstall.html 

Please make the appropriate changes for your system and try again. 

此外,當我做easy_install和壓片我得到這些選項

easy_install  easy_install-2.6 easy_install-2.7 

easy_install-2.6在那裏?

我如何易於安裝工作了?

回答

16

你嘗試使用sudo這樣嗎?

sudo easy_install requests 

或者將安裝目錄指定到您擁有寫入權限的目錄。

easy_install --install-dir=/home/foo/bar 

但是,你真的應該使用PIP,而不是easy_install。它更好,功能更多。

+2

是我沒有'須藤的easy_install requests'但也不能工作。問題是,看起來我的Python路徑有些問題。 easy_install或Python 2.7.2正在尋找我認爲錯誤的路徑。像Python 2.7.2一樣在python2.6/dist-packages目錄中查找。不確定。 – Classer

+0

我也在瀏覽這個,沒有'sudo'或者我只是用它。 – Amanda

4

以下爲我工作與Ubuntu 12.10安裝的easy_install然後pip

sudo apt-get install python-virtualenv 
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py 
sudo python get-pip.py 
2

你有沒有嘗試添加新的python.framework到路徑?我加了 /Library/Frameworks/Python.framework/Versions/3.3/bin//etc/paths 然後我就可以使用easy_install-3.3和pip-3了。3

1

這可能是一個簡單的例子,你錯過了前面的「sudo」。你可以嘗試與sudo易於安裝請求

把「sudo」將添加所需的權限。

1

使用Sudoeasy_install之前可以解決你的問題

Sudo easy_install requests 

感謝