pip install: Please check the permissions and owner of that directory
PythonPipSudoOsx YosemitePython Problem Overview
While installing pip and python I have ran into a that says:
>The directory '/Users/Parthenon/Library/Logs/pi' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag.
because I now have to install using sudo
.
I had python and a handful of libraries already installed on my Mac, I'm running Yosemite. I recently had to do a clean wipe and then reinstall of the OS. Now I'm getting this prompt and I'm having trouble figuring out how to change it
Before my command line was Parthenon$
now it's Philips-MBP:~ Parthenon$
I am the sole owner of this computer and this is the only account on it. This seems to be a problem when upgrading to python 3.4, nothing seems to be in the right place, virtualenv isn't going where I expect it to, etc.
Python Solutions
Solution 1 - Python
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
man sudo
tells me that -H
causes sudo
to set $HOME
to the target users (root in this case).
So it appears pip is looking into $HOME/Library/Log
and sudo
by default isn't setting $HOME
to /root/
. Not surprisingly ~/Library/Log
is owned by you as a user rather than root.
I suspect this is some recent change in pip. I'll run it with sudo -H
for now to work around.
Solution 2 - Python
What is the problem here is that you somehow installed into virtualenv using sudo
. Probably by accident. This means root
user will rewrite Python package data, making all file owned by root and your normal user cannot write those files anymore. Usually virtualenv should be used and owned by your normal UNIX user only.
You can fix the issue by changing UNIX file permissions pack to your user. Try:
$ sudo chown -R USERNAME /Users/USERNAME/Library/Logs/pip
$ sudo chown -R USERNAME /Users/USERNAME/Library/Caches/pip
then pip
should be able to write those files again.
Solution 3 - Python
pip install --user <package name>
(no sudo needed) worked for me for a very similar problem.
Solution 4 - Python
basic info
- system: mac os 18.0.0
- current user: yutou
the key
- add the current account to wheel group
sudo dscl . -append /Groups/wheel wheel $(whoami)
- modify python package mode to 775.
chmod -R 775 ${this_is_your_python_package_path}
the whole thing
- when python3 compiled well, the infomation is just like the question said.
- I try to use
pip3 install requests
and got:
File "/usr/local/python3/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied:
'/usr/local/python3/lib/python3.6/site-packages/requests'
- so i
cd /usr/local/python3/lib/python3.6/site-packages
, thenls -al
and got:
drwxr-xr-x 6 root wheel 192B 2 27 18:06 requests/
when i saw this, i understood, makedirs is an action of write,
but the requests mode drwxrwxr-x
displaied only user root
can write the requests file.
If add yutou(whoami
) to the group wheel, and modify the package
to the group wheel can write, then i can write, and the problem solved.
How to add yutou to group wheel?
- detect group wheel,
sudo dscl . -list /groups GroupMembership
, you will find:
wheel root
the group wheel only one member root.
- add yutou to group wheel,
sudo dscl . -append /Groups/wheel wheel yutou
. - check,
sudo dscl . -list /groups GroupMembership
:
wheel root yutou
modify the python package mode
chmod -R 775 /usr/local/python3/lib/python3.6
Solution 5 - Python
If you altered your $PATH variable that could also cause the problem. If you think that might be the issue, check your ~/.bash_profile or ~/.bashrc