2017-04-20 18 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