pip: inconsistent permissions issues

2019-03-24 05:51发布

When installing a package via sudo pip-python (CentOS 6 package: python-pip-0.8-1.el6.noarch), I sometimes get permission issues with the installed packages being readable only by root.

Re-installing again one or two times usually fixes the problem. Has anyone experienced this? Or can anyone suggest any troubleshooting steps to nail down the cause?

2条回答
smile是对你的礼貌
2楼-- · 2019-03-24 06:08

When you run a command using sudo, it will preserve the users umask. pip just installs files, it doesn't change access rights, so you'll end up with the files having the access rights set conforming to the current user's umask, which may be owner-readable only (0077) and therefore readable by root only.

That means you can set umask to something sensible like umask 0022 before running sudo pip install. Or use sudo su to open a root shell with default settings and then pip install.

查看更多
老娘就宠你
3楼-- · 2019-03-24 06:14

If executing pip with sudo, you may want sudo's -H flag

-H, --set-home set HOME variable to target user's home dir

e.g

sudo -H pip install virtualenv

查看更多
登录 后发表回答