Mac下编译Thrift的时候Python2.7会报错 site-packages': Operation not permitted

具体错误详细如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Making install in py
/usr/local/bin/python setup.py build
running build
running build_py
running build_ext
/Library/Developer/CommandLineTools/usr/bin/make  install-exec-hook
/usr/local/bin/python setup.py install --root=/ --prefix=/usr
running install
running build
running build_py
running build_ext
running install_lib
creating /usr/lib/python2.7/site-packages
error: could not create '/usr/lib/python2.7/site-packages': Operation not permitted
make[4]: *** [install-exec-hook] Error 1
make[3]: *** [install-exec-am] Error 2
make[2]: *** [install-am] Error 2
make[1]: *** [install-recursive] Error 1
make: *** [install-recursive] Error 1

 说明site-packages没有找到准确的位置,我们来看一下python2.7的具体位置在哪里?

1
2
3
4
5
6
7
#输入命令python<br>python<br>
Python 2.7.15 (default, Oct  2 2018, 11:47:18)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import site;site.getsitepackages()
['/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/site-python']
>>>

  位置:/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

也可以自定义位置比如:/Users/xiaoyueya/work/python-path

1
2
xiaoyueya@xiaoyueyadeMacBook-Pro  ~/work/python-path/lib/python2.7/site-packages  <br>pwd
/Users/xiaoyueya/work/python-path/lib/python2.7/site-packages

  然后开始修改编译脚本的

1
--prefix=/Users/xiaoyueya/work/python-path/

  自定义一下pythonPath:

1
2
xiaoyueya@xiaoyueyadeMacBook-Pro  ~/work/python-path echo $PYTHONPATH
:/Users/xiaoyueya/work/python-path

  

 

posted @   linuxone  阅读(1585)  评论(0编辑  收藏  举报
努力加载评论中...
kaochuan
点击右上角即可分享
微信分享提示