这两天又把家里的mac的系统给重装了,重装的原因是我乐意… 其实理由很简单,本人想写个mac osx系统的使用文档,当然是初级的那种… 这尼玛还没意气风发就狼狈不堪了…
该文章写的有些乱,欢迎来喷 ! 另外文章后续不断更新中,请到原文地址查看更新。
各种的新mac其我也用过不少,自己或帮助别人配置了不少环境… 今天就遇到一个十分纠结的问题.
就是想装个python的交互组件ipython、gevent而已….
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#xiaorui.cc
sudo
pip
install
--
upgrade
ipython
--
ignore
-
installed
six
Exception
:
Traceback
(
most
recent
call
last
)
:
File
"/Library/Python/2.7/site-packages/pip/basecommand.py"
,
line
209
,
in
main
status
=
self
.
run
(
options
,
args
)
File
"/Library/Python/2.7/site-packages/pip/commands/install.py"
,
line
317
,
in
run
prefix
=
options
.
prefix_path
,
File
"/Library/Python/2.7/site-packages/pip/req/req_set.py"
,
line
732
,
in
install
*
*
kwargs
File
"/Library/Python/2.7/site-packages/pip/req/req_install.py"
,
line
835
,
in
install
self
.
move_wheel_files
(
self
.
source_dir
,
root
=
root
,
prefix
=
prefix
)
File
"/Library/Python/2.7/site-packages/pip/req/req_install.py"
,
line
1030
,
in
move_wheel_files
isolated
=
self
.
isolated
,
File
"/Library/Python/2.7/site-packages/pip/wheel.py"
,
line
376
,
in
move_wheel_files
clobber
(
source
,
dest
,
False
,
fixer
=
fixer
,
filter
=
filter
)
File
"/Library/Python/2.7/site-packages/pip/wheel.py"
,
line
315
,
in
clobber
ensure_dir
(
destdir
)
File
"/Library/Python/2.7/site-packages/pip/utils/__init__.py"
,
line
83
,
in
ensure_dir
os
.
makedirs
(
path
)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py"
,
line
150
,
in
makedirs
makedirs
(
head
,
mode
)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py"
,
line
150
,
in
makedirs
makedirs
(
head
,
mode
)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py"
,
line
157
,
in
makedirs
mkdir
(
name
,
mode
)
OSError
:
[
Errno
1
]
Operation
not
permitted
:
'/System/Library/Frameworks/Python.framework/Versions/2.7/share'
|
下面是pip install gevent的错误提示, 又是 Operation not permitted …
1
2
3
4
5
6
|
#xiaorui.cc
pip
install
gevent
.
.
.
raise
Error
,
errors
Error
:
[
(
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'
,
'/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'
,
"[Errno 1] Operation not permitted: '/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"
)
,
(
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'
,
'/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'
,
"[Errno 1] Operation not permitted: '/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"
)
,
(
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'
,
'/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'
,
"[Errno 1] Operation not permitted: '/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"
)
,
(
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'
,
'/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'
,
"[Errno 1] Operation not permitted: '/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"
)
,
(
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'
,
'/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'
,
"[Errno 1] Operation not permitted: '/tmp/pip-jlyjj9-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'"
)
]
|
其实权限问题… OSError: [Errno 1] Operation not permitted , 各种的root都不可以,想到了一个粗暴的方式,直接针对share进行chmod的授权。 结果… 提示root也是没有权限操作系统的目录。 我突然发觉肯定是新版的osx有了某种机制制止我们直接的修改/System文档数据。
google了后,发现果然如我的所料…. 新系统有个叫sip的机制。 你暂时不能直接在终端进行 csrutil disable 会出现错误提示,引导你去mac osx的恢复模式进行操作。
由于El Capitan引入了SIP机制(System Integrity Protection),默认下系统启用SIP系统完整性保护机制,无论是对于硬盘还是运行时的进程限制对系统目录的写操作。 这也是我们安装ipython失败的原因….
现在的解决办法是取消SIP机制,具体做法是:
重启电脑,按住Command+R(直到出现苹果标志)进入Recovery Mode(恢复模式)
左上角菜单里找到实用工具 -> 终端
输入csrutil disable回车
重启Mac即可
如果想重新启动SIP机制重复上述步骤改用csrutil enable即可
我们现在再看看sip的状态, 这样再安装ipython、gevent再也不会提示无法写入的权限提示了/
1
2
3
|
$
csrutil
status
System
Integrity
Protection
status
:
disabled
.
|
如果在mac下碰到OSError: [Errno 1] Operation not permitted:的问题,就算用sudo 也无法解决,那肯定是sip在作怪了.
胡阳大哥给出一个优雅的方案,大家可以使用下. 基于用户的权限来安装模块包显得更加合理。
pip install ipython --user -U