2011-10-01 201 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 

感谢