Unable to use easy_install to install Python modules

Classer picture Classer · Oct 1, 2011 · Viewed 69.5k times · Source

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?

Answer

Praveen Gollakota picture Praveen Gollakota · Oct 1, 2011

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.