15

I'm trying to install a virtual environment using the command:

pip install virtualenv

but I get the following error:

IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'

How do I fix this?

Takeshi Patterson
  • 1,207
  • 6
  • 15
  • 29
  • Are you running Linux? Which variant? Also, do you have write permission to the folder? – ilmarinen Jul 01 '14 at 07:21
  • 2
    @ilmarinen that is quite clearly an OSX path name. – tripleee Jul 01 '14 at 08:22
  • 1
    Maybe your `pip` is from homebrew. Check `which pip` to see if its path is `/usr/local/bin/pip`. And from your error message, you were using the system python. You can install a new python via homebrew first, then run `pip install virtualenv` again. – Hong Feb 17 '16 at 13:59

3 Answers3

21

At a glance it looks like you need admin permissions to install packages on your system. Try starting pip as admin or your OS equivalent.

idiot.py
  • 388
  • 2
  • 7
  • 18
    `sudo pip install virtualenv` – Ned Deily Jul 01 '14 at 07:22
  • Takeshi, it would be helpful if you provide some details about you OS environment, to clarify the issue and point us towards the right direction. – idiot.py Jul 01 '14 at 16:48
  • 2
    Why was I downvoted? I don't see the issue with my statement. – idiot.py Jul 01 '14 at 17:00
  • great, running sudo pip install worked great, thanks! – Takeshi Patterson Jul 02 '14 at 19:23
  • Read this for a possible explanation of why you were downvoted (specifically, running pip as sudo can dangerously affect your OS files. You run major risks of harming your system, and there are ways to set up your machine so that you don't need to use sudo.) Using sudo also may install your tools as root, which will further affect the permissions, which will raise the likelihood that you'll need to use sudo to install further tools, opening you up to more risks. See this blog post for how to prevent this. http://blog.manbolo.com/2014/09/27/use-python-effectively-on-os-x – marknuzz Oct 04 '17 at 19:40
  • I tried this suggestion (running under sudo) and got "The directory '/Users/gerard/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag." Seemed to me that the directory permissions were wrong so I deleted it and reinstalled pip. No problems after that. – Gerard Jan 06 '18 at 17:13
4

Your account does not have write access to this directory?.

  1. If the installation directory is a system-owned directory, you may need to sign in as the administrator or "root" account.

    sudo pip install virtualenv
    
  2. 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 PYTHON_PATH environment variable.

  3. easier way: change that dir permission:

    chmod +a 'user:YOUR_USER_NAME allow add_subdirectory,add_file,delete_child,directory_inherit' /Library/Python/2.7/site-packages
    
GabLeRoux
  • 16,715
  • 16
  • 63
  • 81
Luckie Hao
  • 99
  • 4
1

You don't have permission to edit the system-wide version of this library. Try using sudo:

sudo pip install --upgrade virtualenv
jwg
  • 5,547
  • 3
  • 43
  • 57
TeeTracker
  • 7,064
  • 8
  • 40
  • 46
  • This was the solution in my case. `sudo pip2.7 install --upgrade pip` and then `pip2.7 install virtualenv` worked. – hygull Sep 06 '19 at 07:09