unable to install package using pip
<p>I am trying to install module using pip and I get this error:</p>

<pre class="lang-none prettyprint-override"><code>$ 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'
</code></pre>

<p>What is the problem and how can I resolve it?</p>

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

<p><strong>First option</strong>: You can do: </p>

<pre><code>sudo pip install virtualenv
</code></pre>

<p>to download as root user </p>

<p><strong>Second Option</strong>: you could do these commands in sequence in terminal:</p>

<p>First:</p>

<pre><code>cd /Library/Python/2.7/site-packages/pip-8.1.2-py2.7.egg/
</code></pre>

<p>This command will go to the folder you have pip installed in.</p>

<p>Second:</p>

<pre><code>ls -l                                  
</code></pre>

<p>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).</p>

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

<pre><code>sudo chown -R your_username:your_username path/to/pip/
</code></pre>

<p>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.</p>

python pip