早上发现我安装的thrift在python里面无法import。 >>> imp…

早上发现我安装的thrift在python里面无法import。


>>> import thrft.Thrift
Traceback (most recent call last):
File ““, line 1, in
ImportError: No module named thrft.Thrift

我是通过easy_install安装的。看来是easy_install的egg没有被载入。检查发现egg被放在/Library/Python/2.6/site-packages目录下,通过easy-install.pth把它们加入到python的sys.path的eggs里面(方法可以看看easy-install.pth的内容)。我这才知道原来.path文件会被python自动检测的。然后我发现easy_install的eggs都很正常。问题出在python的默认path上。我发现/Library/Python/2.6/site-packages没有被加入到sys.path。所以需要修改默认的python path。在.profile中增加:


export PYTHONPATH=/Library/Python/2.6/site-packages:$PYTHONPATH

然后就OK了,结绳记事。

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.