virtualenv: The directory 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.

I am receiving the following message when trying to install virtualenv via: sudo pip install virtualenv

Bryans-MacBook-Pro:/ BryanB$ sudo pip install virtualenv
The directory '/Users/BryanB/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.
The directory '/Users/BryanB/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

I am unsure how to resolve this issue.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

Try this:

sudo -H pip install virtualenv

Os x has default python install and you’re trying to install in it. I had the same issue but I fixed with the following command sudo pip3 install virtualenv

I solved with sudo chown -R $USERNAME /Users/$USERNAME/Library/Caches/pip, not sure if it helps 😃

python --version if the version is 2 then change it to link to 3 sudo rm /usr/bin/python sudo ln -s /usr/bin/python3 /usr/bin/python

It does matter what you want. The fix is to add -H or fix the systems permissions to give yourself access.

You cloud, also, add an alias to it for yourself so that the inconvenience of hitting two more keys doesn’t affect you… @OrangePJ

1.查看文件的拥有权:ls -l 2.修改文件或目录的拥有权(root权限下):chown -R username 目录 3.系统提示我要修改的是:chown -R xf /home/xf/.cache/pip

Install without sudo as in what I was trying to install, the -H option didn’t install all packages but the install without sudo did it. pip install <package>