I was trying to install igraph in python. I followed the tutorial Installing igraph. I use a macbook, anaconda, python 3.
Things I’ve tried:
$pip install python-igraph
$conda install -c conda-forge python-igraph
installing the C compiler “Xcode”
Installing homebrew and then
$brew install cairo
However, after I use any one of these installation methods, when I tried to import igraph in python, it says “no module named ‘igraph’.” Can anyone help me please? Thanks a lot!
It is quite difficult to know what the problem is with more details.
Could you please try to create a fully reproducible example? Please try to install
igraph in a clean environment, to see what the problem is exactly.
For instance, using conda, you can do the following:
python-igraph in new environment
conda create -n test python-igraph.
- Activate the
conda activate test
- In python run
Please report all output if you encounter any problem.
This is what I get after step 1:
(base) Amyas-MacBook-Pro:~ amyaluo$ conda create -n test python-igraph
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
(some links to anaconda that this forum does not allow me to post)
To search for alternate channels that may provide the conda package you're
looking for, navigate to
and use the search bar at the top of the page.
A small details was missing from Vincent’s answer. Use
conda create -n test python-igraph -c conda-forge
and otherwise follow Vincent’s instructions. This should work.
Thanks that works! But after I activated the test environment, it says
(test) Amyas-MacBook-Pro:~ amyaluo$
And when I run
$import igraph in pycharm, it still says
"no module named 'igraph'." I think I’m missing some steps here. Can you help me? Thanks!
I’m pretty sure that PyCharm tries to work with a different Python environment than the environment you installed
import sys; print(sys.path) tells you which directories the Python interpreter is looking at when it tries to import a module.
import sys; print(sys.executable) tells you the full path of the Python interpreter that you are using. Please verify that
sys.executable points to Anaconda Python’s executable and that
sys.path includes the folder where
igraph was installed in the Anaconda environment.
Thanks for the response. You are right that the environment is different. Apparently my laptop has too many things installed in different places. I have it fixed and now it works.