无法使用easy_install安装Python模块 [英] Unable to use easy_install to install Python modules

查看:417
本文介绍了无法使用easy_install安装Python模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用

easy_install requests

一周前,当我使用Python 2.6.5时,此方法运行良好,但今天我安装了Python 2.7.2,然后尝试在我的一个脚本中执行import requests,但失败了.然后,我尝试使用easy_install requests重新安装请求,但收到此错误

This worked fine a week ago when I was using Python 2.6.5 but today I installed Python 2.7.2 and then tried to import requests in one of my scripts but it failed. I then tried reinstalling requests with easy_install requests but got this error

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 ,并得知我必须

So I was told to go reinstall easy_install and I went to http://pypi.python.org/pypi/setuptools and learned I had to

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

delete all setuptools*.egg and setuptools.pth files from your system's site-packages directory (and any other sys.path directories) FIRST.

所以我做到了.然后,我从setuptools-0.6c11-py2.7.egg重新安装了setuptools.看起来很成功,但是当我运行easy_install requests时,除了出现目录python2.6/dist-packages现在是python2.7/site-packages

So I did this. I then reinstalled setuptools from the setuptools-0.6c11-py2.7.egg. It seemed successful but when I ran easy_install requests I got basically the same error except the directory python2.6/dist-packages is now 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键时,我会得到以下选项

Also, when I do easy_install and press tab I get these options

easy_install      easy_install-2.6  easy_install-2.7

easy_install-2.6为何出现?

How come easy_install-2.6 is there?

如何重新安装易用的软件?

推荐答案

您尝试像这样使用sudo吗?

sudo easy_install requests

或将安装目录指定为您具有写权限的目录.

Or specify the install directory to a directory that you have write privileges.

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

但是您应该真正使用 PIP 而不是easy_install.它要好得多,并具有更多功能.

But you should really use PIP instead of easy_install. It is much better and has a lot more features.

这篇关于无法使用easy_install安装Python模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆