Reputation: 31
I am new in graph_tool
. I have installed this library using this tutorial. Then I launched idle (Python 3) and tried to import it, but got this error:
Traceback (most recent call last):
File "/home/ihor/CS/Python_lessons/graph_tool_test.py", line 1, in <module>
from graph_tool.all import *
ModuleNotFoundError: No module named 'graph_tool'
Upvotes: 2
Views: 9654
Reputation: 49
With Brew try the following commands:
brew tap brewsci/bio
brew tap brewsci/science
brew install graph-tool
With anaconda:
conda config --add channels vgauthier --add channels rwest
conda install graph-tool
Upvotes: -1
Reputation: 6493
If you are using virtualenv (or pyenv virtualenv) on a Mac, then this worked for me. You essentially need to put graph-tool into the right package directory. As brew and other installers target the incorrect folder. Here is a guide:
First, locate where graph-tool was actually installed:
brew info graph-tool
graph-tool: stable 2.43
Efficient network analysis for Python 3
https://graph-tool.skewed.de/
/usr/local/Cellar/graph-tool/2.43 (2,077 files, 576.8MB) *
... The rest bellow here is irrelevant...
Here you can see that graph-tool was installed here at /usr/local/Cellar/graph-tool/2.43
Now dig into the /lib
folder here and locate the site-packages
folder inside the relevant python version. Mine was:
/usr/local/Cellar/graph-tool/2.43/lib/python3.9/site-packages/graph_tool
Secondly locate where your python packages usually are. You can do this by entering the Python terminal, importing a package and then calling __file__
on it. Example:
>>>> import pandas as pd
>>>> pd.__file__
'/Users/some_user/.pyenv/versions/my_project/lib/python3.9/site-packages/pandas/__init__.py'
You can now see that your packages installed with pip are located in:
/Users/some_user/.pyenv/versions/my_project/lib/python3.9/site-packages
All you need to do is to add graph_tool to this folder through a symlink. Like so ln-s <graph-tool-packages-directory> <vitrualenv-packages-directory>
. Example:
ln -s /usr/local/Cellar/graph-tool/2.43/lib/python3.9/site-packages/graph_tool /Users/some_user/.pyenv/versions/my_project/lib/python3.9/site-packages
There might be much better ways of doing this, but this worked for me.
Upvotes: 6