2

Installed graph-tool via homebrew using $ brew install graph-tool

Installation was successful. Now, when I try to import the module in the python shell, using from graph_tool.all import *

I receive a ModuleNotFoundError: No module named 'graph_tool' error

Python version info- Python 3.8.5, installed via pyenv at /Users/aamodpant/.pyenv/shims/python

graph-tool installed in /usr/local/Cellar/graph-tool

How do I import this into my python program?

Tiago Peixoto
  • 5,149
  • 2
  • 28
  • 28
Aamod Pant
  • 21
  • 4

3 Answers3

0

This looks like a very similar issue to the one in this post: How to let python3 import graph-tool installed by Homebrew?

Have a look at the top answer provided by NatKost where they created a symbolic link between graph-tool and the Python packages:

ln -s /usr/local/Cellar/graph-tool/2.26_2/lib/python3.6/site-packages/graph_tool /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages

You should be able adapt this for your graph-tool install and your venv.

Robert Young
  • 456
  • 2
  • 8
  • This worked! Although now I am getting a similar error with error with numpy. `ModuleNotFoundError: No module named 'numpy'`. numpy is also installed from brew. Do I add a similar "symbolic link" from numpy to graph-tool? – Aamod Pant Aug 04 '20 at 12:40
  • How did you install numpy? When using Python it's best to install packages using pip. So for example, when you have your venv active in the terminal, you would call 'pip install numpy' and this would install this package directly to your active virtual environment. – Robert Young Aug 04 '20 at 12:42
  • 1
    Hey, numpy was installed as a dependency for graph-tool automatically, therefore home-brew was used. I added 2 more symbolic links, and now it works. I am going to post an answer with all the commands I used. Thank you so much for your help!! – Aamod Pant Aug 04 '20 at 12:52
0

Check this site here and see whehter your problem is fixed. Alternatively, check this post here

I would recommend installing using pip.

Safwan Samsudeen
  • 1,645
  • 1
  • 10
  • 25
  • `graph-tool` cannot be installed with `pip`, because `pip` is not a suitable package manager for projects with complex C++ builds with many dependencies. It is available via conda-forge, however. – Stuart Berg Aug 09 '20 at 19:24
-1

Thanks @Robert Young, for leading me to the right post How to let python3 import graph-tool installed by Homebrew?

Because numpy and scipy are dependencies of graph-tool, they were installed automatically using home-brew when installing graph-tool.

After editing the command shown in the linked solution, I added a symbolic link between graph-tool and my python

ln -s /usr/local/Cellar/graph-tool/2.33/lib/python3.8/site-packages/graph_tool /Users/aamodpant/.pyenv/versions/3.8.5/lib/python3.8/site-packages

added similar links between numpy, scipy and python

ln -s /usr/local/Cellar/numpy/1.19.1/lib/python3.8/site-packages/numpy /Users/aamodpant/.pyenv/versions/3.8.5/lib/python3.8/site-packages
ln -s /usr/local/Cellar/scipy/1.5.2/lib/python3.8/site-packages/scipy /Users/aamodpant/.pyenv/versions/3.8.5/lib/python3.8/site-packages
Aamod Pant
  • 21
  • 4