unable to install package using pip

Tags: python pip
By : raju
Source: Stackoverflow.com
Question!

I am trying to install module using pip and I get this error:

$ pip install virtualenv

Collecting virtualenv
  Downloading virtualenv-15.0.3-py2.py3-none-any.whl (3.5MB)
    100% |????????????????????????????????| 3.5MB 312kB/s
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line 742, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 831, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 1032, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 346, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/pip/wheel.py", line 324, in clobber
    shutil.copyfile(srcfile, destfile)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'

What is the problem and how can I resolve it?

By : raju


Answers

It's probably because the user you are logged as can't install to that folder.

First option: You can do:

sudo pip install virtualenv

to download as root user

Second Option: you could do these commands in sequence in terminal:

First:

cd /Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/

This command will go to the folder you have pip installed in.

Second:

ls -l                                  

This command will show permissions for files/folders. In on the of the columns you will see users who has access to folder pip (eg. root).

Third: Change it to the user you are logged in as with instead of root:

sudo chown -R your_username:your_username path/to/pip/

This is assuming that folders up in the hierarchy don't have root permissions, otherwise you would need to change them too. I'm talking about: Library, Python etc.



the problem is caused because you have not given the super user permission to the system. in order to make any changes into the system you should go to super user mode, for that you have to type the code as

sudo pip install virtualenv

it will help you out



This video can help you solving your question :)
By: admin