无法使用easy_install来安装Python模块

Cla*_*ser 14 python installation module setuptools easy-install

我试图使用easy_install安装一个模块调用的请求

easy_install requests
Run Code Online (Sandbox Code Playgroud)

一周前我使用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.
Run Code Online (Sandbox Code Playgroud)

所以我被告知重新安装easy_install,然后我去了http://pypi.python.org/pypi/setuptools并了解到我必须

从系统的site-packages目录(以及任何其他sys.path目录)中删除所有setuptools*.egg和setuptools.pth文件.

所以我这样做了.然后我重新安装了setuptools setuptools-0.6c11-py2.7.egg.它看起来很成功,但是当我跑的时候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.
Run Code Online (Sandbox Code Playgroud)

此外,当我这样做easy_install并按Tab键我得到这些选项

easy_install      easy_install-2.6  easy_install-2.7
Run Code Online (Sandbox Code Playgroud)

怎么来easy_install-2.6?

如何轻松安装再次工作?

Pra*_*ota 15

你尝试过sudo这样的吗?

sudo easy_install requests
Run Code Online (Sandbox Code Playgroud)

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

easy_install --install-dir=/home/foo/bar
Run Code Online (Sandbox Code Playgroud)

但你真的应该使用PIP而不是easy_install.它更好,并具有更多功能.

  • 是的,我做了'sudo easy_install requests`但这也没有用.关键是我的Python路径似乎已经破坏了某些东西.easy_install或Python 2.7.2正在寻找我认为错误的路径.像Python 2.7.2正在查看python2.6/dist-packages目录.不确定. (2认同)

Fed*_*ico 5

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

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