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.

Created on 24 Nov 2016  ·  19Comments  ·  Source: pypa/virtualenv

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.

Most helpful comment

Try this:

sudo -H pip install virtualenv

All 19 comments

Try this:

sudo -H pip install virtualenv

Message received after trying sudo -H pip install virtualenv

Requirement already satisfied: virtualenv in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

Overall goal is to setup my machine for this: http://newcoder.io/begin/setup-your-machine/#mac-os-x

Is there a file virtualev in /Library/Frameworks/Python.framework/Versions/2.7/bin?

Yes

Requirement already satisfied: virtualenvwrapper in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requirement already satisfied: virtualenv in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from virtualenvwrapper)
Requirement already satisfied: virtualenv-clone in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from virtualenvwrapper)
Requirement already satisfied: stevedore in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from virtualenvwrapper)
Requirement already satisfied: six>=1.9.0 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied: pbr>=1.6 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from stevedore->virtualenvwrapper)

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 also saw this change on my Mac when I went from running 'pip' to 'sudo pip'

Adding '-H' to sudo causes the message to go away for me. E.g.

sudo -H pip install foo

But I don't want to add -H every time. when I use sudo pip3 install virtualenvwrapper every time,it will show the warning. Who can help me

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

@Ekultek fine...

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

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

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

when i use sudo pip3 install requests it shows this massage but i used just pip3 install requests it installed package.

For some reason, I had to add python to the PATH and this solved my problem.

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>

This is related to provisioning virtualenv for the system, and it's OS dependent probably. As there's no actionable item for the package itself I'll close this.

Sorry to bring this thread back to life, but I am still experiencing a problem with my module not importing correctly. This is error message I get when I try importing the module "pyperclip"

>>> import pyperclip
Traceback (most recent call last):
  File “<stdin>”, line 1, in <module>
ModuleNotFoundError: No module named ‘pyperclip’
>>> 

Can anyone help?
I am using Mac OS X
Python version 3.8.3

This is what I get when I try installing pyperclip via sudo -H pip3 install pyperclip

Requirement already satisfied: pyperclip in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.8.0)

btw I am a newbie. Terminal is foreign to me.

Thanks in advance everyone.

@SecureTheBeans your question has nothing to do with virtualenv, your question is more appropriate at https://discuss.python.org/c/users/7

My bad. I didn’t know this was exclusive to virtualenv.

I received the same outputted message from Terminal after trying to install the module pyperclip through sudo pip install and figured the issues were similar enough. Anyways I figured out what was going on. The interpreter I was using was not the same where pip was installing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

npinto picture npinto  ·  4Comments

erbatyr picture erbatyr  ·  5Comments

asottile picture asottile  ·  6Comments

neildhar picture neildhar  ·  4Comments

vbabiy picture vbabiy  ·  4Comments