'pip install <package>'一致权限被拒绝</package>

时间:2015-01-14 08:50:26

标签: python permissions pip sudo

我刚开始构建一个新的macbook pro。我是管理员用户。如果我运行pip命令,我一直得到权限拒绝错误:

  

权限被拒绝:&#39; /lib/python2.7/site-packages /&#39;

当我跑步时

$ sudo pip install <package>

我收到此错误:

The directory '/Users/nate_argetsinger/Library/Logs/pip' 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.
The directory '/Users/nate_argetsinger/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 the -H flag.
The directory '/Users/nate_argetsinger/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 the -H flag.

添加-H标志可以抑制错误。

最后,我相信我是拥有错误消息所引用目录的用户:

➜  startbootstrap-agency git:(gh-pages) ✗ ls -l 

...

drwx------  3 nate_argetsinger  staff  102 Jan 14 03:29 c
drwx------  3 nate_argetsinger  staff  102 Jan 14 03:42 d
drwx------  5 nate_argetsinger  staff  170 Jan 14 03:29 f
➜  startbootstrap-agency git:(gh-pages) ✗ whoami
nate_argetsinger
➜  startbootstrap-agency git:(gh-pages) ✗

提前致谢。

1 个答案:

答案 0 :(得分:2)

您的主目录上的权限似乎已损坏,很可能是由于sudo的使用不当造成的。

解决此问题的最佳方法是运行&#34;修复磁盘权限&#34;磁盘工具中的选项。