首页 文章

无法使用easy_install来安装Python模块

提问于
浏览
14

我正在尝试使用 easy_install 来安装一个名为 requests 的模块

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并且知道我必须这样做

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

所以我这样做了 . 然后我从 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 回答

  • 5

    你尝试过这样的 sudo 吗?

    sudo easy_install requests
    

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

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

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

  • 4

    您应该在基于软件包的Linux发行版上使用 virtualenv ,因此Python脚本不需要't interfere with other packages or conflict with the OS'的软件包管理器 .

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

  • 2

    以下是使用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

  • 16

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

    Sudo easy_install requests
    

    谢谢

  • 0

    这可能是一个简单的例子,你在前面错过了“sudo” . 你可以尝试使用sudo easy-install请求

    放“sudo”将添加所需的权限 .

相关问题