2017-04-20 17 views
3

我试图用Homebrew来安装graph-tool,但是python3找不到它。如何让python3导入图形工具由Homebrew安装?

brew tap homebrew/science 
    brew install graph-tool 

据说,该软件包安装在homebrew/science/graph-tool-2.22_1,在那里我才发现/usr/local/Homebrew/Library/Taps/homebrew/homebrew-science/graph-tool.rb

当我试图在python3导入图形工具,它表明 from graph_tool.all import * ImportError: No module named 'graph_tool'

我使用python3。

which python3 /usr/local/bin/python3

有没有一种方法,我可以使用安装在家酿的graph_tool包?

任何帮助,将不胜感激。

回答

0

快速解决方案。

要检查酿造安装包路径在控制台中,

brew --prefix graph-tool

然后在代码的开头,追加路径。

import sys 
    sys.path.append('/usr/local/Cellar/graph-tool/2.22_1/lib/python2.7/site-packages/') 
    from graph_tool.all import * 
0

它应该工作的方式是与通过--with-python3酿造:

brew install graph-tool --with-python3

但它会导致重建图形工具和需要matplotlib,numpy的和SciPy的的从brew改为pip,这并不是很吸引人,因为最近的稳定版本networkx还不与matplotlib兼容(固定在主版本上),所以我宁愿用这个:

brew install graph-tool --with-python3 --without-matplotlib --without-numpy --without-scipy

告诉the formula不要寻找brew安装的matplotlib/numpy/scipy。

而且因为某些原因我不能使用与python2支持,我也没在意公式,所以我结束了:

brew install graph-tool --without-python --with-python3 --without-matplotlib --without-numpy --without-scipy