变更记录

序号 录入时间 录入人 备注
1 2017-10-24 Alfred Jiang -

方案名称

Mac 系统 - 解决 SIP 机制导致的 OSError 权限问题

关键字

Mac 系统 \ SIP \ 权限

需求场景

  1. 由于 El Capitan 引入了 SIP 机制(System Integrity Protection),默认下系统启用 SIP 系统完整性保护机制,无论是对于硬盘还是运行时的进程限制对系统目录的写操作

参考链接

  1. xiaorui.cc - 解决mac osx下pip安装ipython权限的问题(推荐)

详细内容

如果在 Mac 下碰到 OSError: [Errno 1] Operation not permitted: 的问题,就算用 sudo 也无法解决,可以考虑通过禁用 SIP 来解决问题

具体步骤如下:

  1. 重启电脑,按住 Command+R (直到出现苹果标志)进入 Recovery Mode (恢复模式)
  2. 左上角菜单里找到 实用工具 -> 终端
  3. 输入 csrutil disable 回车
  4. 重启 Mac 即可
  5. 如果想重新启动 SIP 机制重复上述步骤改用 csrutil enable 即可

重启后,可以通过下面命令检查 SIP 状态:

1
2
$ csrutil status
System Integrity Protection status: disabled.

可选替代方案:

1
pip install ipython --user -U

效果图

(无)

备注

(无)