How do I let the python3 import graphical tool installed by Homebrew?

I tried using Homebrew to install graph-tool , but python3 can't find it.

    brew tap homebrew/science
    brew install graph-tool

      

The package is said to be installed homebrew/science/graph-tool-2.22_1

where I found only /usr/local/Homebrew/Library/Taps/homebrew/homebrew-science/graph-tool.rb

.

When I tried to import the graphical tool in python3 it shows that from graph_tool.all import *

ImportError: No module named 'graph_tool'

I am using python3.

which python3 /usr/local/bin/python3

Is there a way to use the graph_tool package installed in Homebrew?

Any help would be appreciated.

+3


source to share


2 answers


Fast decision.

To check brew installed package path in console,

brew --prefix graph-tool



Then add the path at the beginning of the code.

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

      

0


source


The way it should work is by passing --with-python3 to brew:

brew install graph-tool --with-python3

But this leads to a rebuilding of the graphing tool and the need to use matplotlib, numpy and scipy from brew instead of pip, which is not very attractive since the recent stable version of networkx is not matplotlib compatible yet (fixed on master), so I'd rather go with this:

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



which tells the formula to not look for brew installed by matplotlib / numpy / scipy.

And for some reason I couldn't use the python2-backed formula, which I didn't care, so I ended up with:

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

0


source







All Articles