无法使用easy_install来安装Python模块

时间:2011-10-01 19:52:50

标签: python module installation setuptools easy-install

我正在尝试使用easy_install来安装名为请求的模块

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.pth文件   system的site-packages目录(以及任何其他sys.path目录)   FIRST。

所以我这样做了。然后我从setuptools-0.6c11-py2.7.egg重新安装了setuptools。它看起来很成功,但是当我运行easy_install requests时我得到了基本相同的错误,除了目录python2.6 / dist-packages现在是python2.7 / site-packages

siddhion@siddhion-laptop:~$ 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并按Tab键时,我会获得这些选项

easy_install      easy_install-2.6  easy_install-2.7

为什么easy_install-2.6会在那里?

如何让再次轻松安装?

6 个答案:

答案 0 :(得分:16)

您是否尝试过这样的sudo

sudo easy_install requests

或者将安装目录指定给您具有写权限的目录。

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

但您应该使用PIP代替easy_install。它功能更好,功能更多。

答案 1 :(得分:5)

您应该在基于软件包的Linux发行版上使用virtualenv,这样Python脚本不会干扰其他软件包或与操作系统的软件包管理器发生冲突。

http://workaround.org/easy-install-debian

答案 2 :(得分: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

答案 3 :(得分:2)

您是否尝试将新的python.framework添加到路径? 在山狮上我补充道 /Library/Frameworks/Python.framework/Versions/3.3/bin//etc/paths 然后我就可以使用easy_install-3.3和pip-3.3

答案 4 :(得分:2)

Sudo之前使用easy_install可以解决您的问题

Sudo easy_install requests

谢谢

答案 5 :(得分:0)

这可能是一个你想念的简单案例" sudo"在前面。你能用sudo easy-install requests来试试吗

把" sudo"将添加所需的权限。