简体   繁体   English

无法使用easy_install安装Python模块

[英]Unable to use easy_install to install Python modules

I am trying to use easy_install to install a module called requests by doing 我正在尝试使用easy_install通过执行安装名为请求的模块

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. 一周前,当我使用Python 2.6.5时,此方法运行良好,但今天,我安装了Python 2.7.2,然后尝试在我的一个脚本中import requests ,但失败了。 I then tried reinstalling requests with easy_install requests but got this error 然后,我尝试使用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.

So I was told to go reinstall easy_install and I went to http://pypi.python.org/pypi/setuptools and learned I had to 因此,我被告知要重新安装easy_install,然后我去了http://pypi.python.org/pypi/setuptools ,得知我必须

delete all setuptools*.egg and setuptools.pth files from your system's site-packages directory (and any other sys.path directories) FIRST. 首先从系统的site-packages目录(和任何其他sys.path目录)中删除所有setuptools * .egg和setuptools.pth文件。

So I did this. 所以我做到了。 I then reinstalled setuptools from the setuptools-0.6c11-py2.7.egg . 然后,我从setuptools-0.6c11-py2.7.egg重新安装了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 似乎成功了,但是当我运行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.

Also, when I do easy_install and press tab I get these options 另外,当我执行easy_install并按tab时,我会获得以下选项

easy_install      easy_install-2.6  easy_install-2.7

How come easy_install-2.6 is there? easy_install-2.6为何出现?

and

How do I get easy-install working again? 如何使易安装的产品再次工作?

Did you try using sudo like this? 您是否尝试过像这样使用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

But you should really use PIP instead of easy_install . 但是您应该真正使用PIP而不是easy_install It is much better and has a lot more features. 它要好得多,并具有更多功能。

You should use virtualenv on package-based Linux distributions so Python scripts don't interfere with other packages or conflict with the OS's package-manager. 您应该在基于软件包的Linux发行版上使用virtualenv ,这样Python脚本就不会干扰其他软件包或与操作系统的软件包管理器冲突。

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

The following worked for me with Ubuntu 12.10 installing easy_install then pip : 以下对我有用的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

Have you tried adding your new python.framework to path? 您是否尝试过将新的python.framework添加到path? On mountain lion I added /Library/Frameworks/Python.framework/Versions/3.3/bin/ to /etc/paths and then I was able to use easy_install-3.3 and pip-3.3 在山狮上,我将/Library/Frameworks/Python.framework/Versions/3.3/bin/添加到/etc/paths ,然后可以使用easy_install-3.3和pip-3.3

Using Sudo before easy_install may solve your problem easy_install之前使用Sudo可能会解决您的问题

Sudo easy_install requests

thanks 谢谢

It might be a simple case of you missing "sudo" in the front. 这可能是您在前面缺少“ sudo”的简单情况。 Can you try it with sudo easy-install requests 您可以使用sudo简易安装请求尝试吗

putting the "sudo" will add the required permissions. 放置“ sudo”将添加所需的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM