您的位置:首页 > 编程语言 > Python开发

用homebrew安装protobuf提示找不到包的解决办法

2017-03-03 12:21 543 查看
用homebrew安装protobuf:

命令 brew install protobuf

命令执行之后:

安装位置: /usr/local/Cellar
软连接位置: /usr/local/lib/python2.7/site-packages

我安装protobuf时的提示:

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

这一条路径

=======================================================
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python brew
相关文章推荐