用homebrew安装protobuf:
命令 brew install protobuf
命令执行之后:
安装位置: /usr/local/Cellar软连接位置: /usr/local/lib/python2.7/site-packages
Python modules have been installed and Homebrew's site-packages is not
in your Python sys.path, so you will not be able to import the modules
this formula installed. If you plan to develop with these modules,
please run:
mkdir -p /Users/zj_macbook/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/zj_macbook/Library/Python/2.7/lib/python/site-packages/homebrew.pth
上面这些操作是创建了一个位于
/Users/zj_macbook/Library/Python/2.7/lib/python/site-packages
的文件
homebrew.pth
指向
/usr/local/lib/python2.7/site-packages
内容为:
import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")
这样做可以的原因是/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python这个python的sys.path的路径中有
/Users/zj_macbook/Library/Python/2.7/lib/python/site-packages
这一条路径
=======================================================