Unable to use easy_install to install Python modules

旧城冷巷雨未停 提交于 2019-12-18 11:27:05

问题


I am trying to use easy_install to install a module called requests by doing

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.

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

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

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.

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

easy_install      easy_install-2.6  easy_install-2.7

How come easy_install-2.6 is there?

and

How do I get easy-install working again?


回答1:


Did you try using sudo like this?

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. It is much better and has a lot more features.




回答2:


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.

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




回答3:


The following worked for me with Ubuntu 12.10 installing easy_install then 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



回答4:


Have you tried adding your new python.framework to 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




回答5:


Using Sudo before easy_install may solve your problem

Sudo easy_install requests

thanks




回答6:


It might be a simple case of you missing "sudo" in the front. Can you try it with sudo easy-install requests

putting the "sudo" will add the required permissions.



来源:https://stackoverflow.com/questions/7622562/unable-to-use-easy-install-to-install-python-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!