No module named thrift in Python script

Gre*_*reg 5 python homebrew thrift

I've installed Thrift on my Mac using Homebrew: brew install thrift --with-python

That did some work and finished w/o errors reported. I have thrift on my path.

I write a simple python client from a tutorial: (there is some python thrift code in gen-py)

#!/usr/bin/python

import sys
sys.path.append("./gen-py")

from thrift import Thrift
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol

# rest of program...
Run Code Online (Sandbox Code Playgroud)

When run I get this error:

Traceback (most recent call last):
  File "./hey.py", line 8, in <module>
    from thrift import Thrift
ImportError: No module named thrift
Run Code Online (Sandbox Code Playgroud)

Did I installed python correctly using Homebrew? Is there a way I can verify the python/thrift integration is installed properly?

Gre*_*reg 6

事实证明(撰写本文时的当前版本)用于 Thrift 安装的 Homebrew 配方并没有完全安装 Python 的所有内容,特别是库。(它确实成功安装了 thrift 命令行工具。)

我通过下载 python 发行版并在我的 Mac 上构建它来解决这个问题——但没有安装,因为我已经完成了 brew 安装。我只想要 python 库。

我在这里遵循了建议:http : //thrift-tutorial.readthedocs.org/en/latest/usage-example.html 我按照描述运行了“sudo python setup.py install”,这正确(显然)安装了所需的库和东西在那之后工作。